Skip to content

Commit

Permalink
Merge pull request #471 from andreban/service-connection-oncreatedestroy
Browse files Browse the repository at this point in the history
Move connecting/disconnecting from service to onCreate/Destroy
  • Loading branch information
andreban authored May 21, 2024
2 parents 6d1272a + 98a633c commit 2945ee4
Showing 1 changed file with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down

0 comments on commit 2945ee4

Please sign in to comment.