简体   繁体   English

如何在外部浏览器中打开Android应用程序中的链接?

[英]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中打开链接时显示浏览器列表

在此输入图像描述

            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.co.in/"));


            String title = "Complete Action Using";

            Intent chooser = Intent.createChooser(intent, title);
            startActivity(chooser);

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.

相关问题 电容器 Android 应用程序外部链接未在外部浏览器中打开 - Capacitor Android app external links does not open in external browser 如何打开外部链接到android中的相关应用程序 - how to open external links in to there relevant app in android 如何在 Android 的 WebView 的外部浏览器和应用程序内打开链接 - How to open links both in an external browser and in-app within a WebView for Android Android Webview-如何在默认浏览器中打开外部链接? - Android Webview - How I can open external links in default browser? phonegap jquerymobile:如何通过Android浏览器打开外部链接 - phonegap jquerymobile : how to open external links via Android Browser 使用android webview在浏览器中打开外部链接 - Open external links in the browser with android webview 如何在浏览器中打开外部 WebView 链接? - How to Open External WebView Links in Browser? Instagram 链接打开应用内浏览器而不是外部/本机浏览器 - Instagram links open in-app browser instead of external/native browser 如何直接在应用内浏览器(Chrome 自定义选项卡)中打开外部链接,而不提示浏览器 select - How to open external links directly in in-app browser (Chrome custom tab) without getting prompt to select the browser WebView应用程序:仅在Mob浏览器中打开外部链接 - WebView App: Only Open External Links In Mob Browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM