@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_serviceconnection);

        customTabActivityHelper = new CustomTabActivityHelper();
        customTabActivityHelper.setConnectionCallback(this);

        mUrlEditText = (EditText) 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);
    }
This Activity connect to the Chrome Custom Tabs Service on startup, and allows you to decide
when to call mayLaunchUrl.
demos/src/main/java/org/chromium/customtabsdemos/ServiceConnectionActivity.java