简体   繁体   中英

How can I use google chrome as a reference in android studio?

I don't know if this is possible or not but I was wondering. Is it possible to reference google chrome (app) in android studio? I was thinking about making an app that reference the google chrome app and have the app display the current url open in chrome, have else if statements for the url to change in chrome and maybe have show text of what url is being display in chrome in my app. I have been doing research and couldn't find any on this but found out there is ways to develop things in google chrome like custom tabs , Homescreen and etc.

So, I thought maybe I would post my question here and see if anyone can help me or tell me if my request is possible?

Thank you in advance for the advice!

Yes, it's possible to open URLs in a specific browser.

But it's frowned upon because it'll most likely throw an ActivityNotFoundException exception if the target application is not installed for some reason.

You're better off giving the user the option to choose which browser they'd like to open the URL in.

An example of how to open a URL is as follows:

String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM