Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How do I make a Chrome Custom Tab open using a button or a link on my android app?

I created an Android app that opens a Chrome Custom Tab. The problem is that I want to make the custom chrome tab not the first thing that shows up. I want to add a button or hyperlink that makes the custom chrome tab appear. As in when the app starts the first thing that shows up is a button or hyperlink that opens up a Custom Chrome Tab. Here is my code of my MainActivity.java what do I need to change:

public class MainActivity extends AppCompatActivity {
    private AdView mAdView;

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

        // Use a CustomTabsIntent.Builder to configure CustomTabsIntent.
        String url = "https://speedwaygroceries.net/index.php?route=account/login";
        CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
        // set toolbar color
        builder.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
// set toolbar color and/or setting custom actions before invoking build()
// Once ready, call CustomTabsIntent.Builder.build() to create a CustomTabsIntent
        CustomTabsIntent customTabsIntent = builder.build();


// and launch the desired Url with CustomTabsIntent.launchUrl()
        customTabsIntent.launchUrl(this, Uri.parse(url));

Comments