Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move connecting/disconnecting from service to onCreate/Destroy #471

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading