diff --git a/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnectionActivity.java b/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnectionActivity.java index 140685e9..366f21e9 100644 --- a/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnectionActivity.java +++ b/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnectionActivity.java @@ -36,21 +36,23 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_serviceconnection); - customTabActivityHelper = new CustomTabActivityHelper(); - customTabActivityHelper.setConnectionCallback(this); - mUrlEditText = findViewById(R.id.url); mMayLaunchUrlButton = findViewById(R.id.button_may_launch_url); mMayLaunchUrlButton.setEnabled(false); mMayLaunchUrlButton.setOnClickListener(this); findViewById(R.id.start_custom_tab).setOnClickListener(this); + + customTabActivityHelper = new CustomTabActivityHelper(); + customTabActivityHelper.setConnectionCallback(this); + customTabActivityHelper.bindCustomTabsService(this); } @Override protected void onDestroy() { super.onDestroy(); customTabActivityHelper.setConnectionCallback(null); + customTabActivityHelper.unbindCustomTabsService(this); } @Override @@ -63,19 +65,6 @@ public void onCustomTabsDisconnected() { mMayLaunchUrlButton.setEnabled(false); } - @Override - protected void onStart() { - super.onStart(); - customTabActivityHelper.bindCustomTabsService(this); - } - - @Override - protected void onStop() { - super.onStop(); - customTabActivityHelper.unbindCustomTabsService(this); - mMayLaunchUrlButton.setEnabled(false); - } - @Override public void onClick(View view) { int viewId = view.getId();