简体   繁体   中英

How to open an url from android webview app in another app

I am making an Android webview app to share some useful urls. And when user clicks on a url, it should be opened in a targeted app like facebook, neither in external browser, nor inside the webview. How could I do that? Thank you for your help.

you can do this with the help of Intent.

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, 
"https://play.google.com/store/apps/details?id=" + 
BuildConfig.APPLICATION_ID);
sendIntent.setType("text/plain");

startActivity(sendIntent);

use JavaScriptInterface to pass deepLink from webView to your java/kotlin class and just open that deep link there!

see JavaScriptInterface and deepLink

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