[英]How to open links in Android app in external browser?
Can anyone help me in Code for opening links in external browsers or other Android app? 任何人都可以帮助我在Code中打开外部浏览器或其他Android应用程序中的链接?
Now the case is the link is opening in the app itself. 现在案例是链接在应用程序本身打开。 But if the link belongs to an android app its not opening. 但如果链接属于Android应用程序,它不会打开。 It's showing install the Android app. 它显示安装Android应用程序。
So I want that if the link can be opened in browsers, then it will ask from a list of browsers. 所以我希望如果链接可以在浏览器中打开,那么它会从浏览器列表中询问。 Or if the links belongs to an app it must show the app in the list too. 或者,如果链接属于某个应用,则它也必须在列表中显示该应用。
Something like this could work 像这样的东西可以工作
Intent browserIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.google.com"));
startActivity(browserIntent);
As @zain posted ago you can use. 正如@zain发布前你可以使用。
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.stackoverflow.com"));
startActivity(intent);
But if you have more then one browser installed in device and want to choose from one of them. 但是,如果您在设备中安装了多个浏览器,并希望从其中一个中进行选择。 Use intent chooser like this 像这样使用意图选择器
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.stackoverflow.com"));
// Always use string resources for UI text. This says something like "Share this photo with"
String title = getResources().getText(R.string.chooser_title);
// Create and start the chooser
Intent chooser = Intent.createChooser(intent, title);
startActivity(chooser);
refer from here Show browser list when opening a link in android 从这里开始在android中打开链接时显示浏览器列表
If you are in a WebView in your App, and on clivking a link there, if the app opens the link in the App Itself, Then possibly u should have overridden this method. 如果你在你的应用程序中使用WebView,并且在那里使用链接,如果应用程序打开了App Itself中的链接,那么可能你应该覆盖这个方法。
myWebView.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
//view.loadUrl(url);
return false;
}
});
The return of false should ask the user, where to Open the link. 返回false应该询问用户,在哪里打开链接。 With the browsers installed in the mobile 随着浏览器安装在移动设备上
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.