2

任何人都可以帮助我在代码中打开外部浏览器或其他Android应用程序的链接?如何在外部浏览器中打开Android应用中的链接?

现在情况是链接在应用程序本身打开。但是,如果链接属于一个Android应用程序,它不会打开。它显示安装Android应用程序。

所以我想,如果链接可以在浏览器中打开,那么它会问一个浏览器列表。或者,如果链接属于某个应用程序,则它也必须在列表中显示该应用程序。

回答

5

像这样的东西可以工作

Intent browserIntent = new Intent(Intent.ACTION_VIEW, 
Uri.parse("http://www.google.com")); 
startActivity(browserIntent); 
-1

如果您在您的应用中的WebView,并在clivking链接出现,如果应用程序打开的应用程序本身的链接,然后可能ü应该已经覆盖这种方法。

myWebView.setWebViewClient(new WebViewClient()  
    { 
     @Override 
     public boolean shouldOverrideUrlLoading(WebView view, String url) 
     { 
      //view.loadUrl(url); 

      return false; 
     } 
    }); 

回报应该询问用户,在打开的链接。随着浏览器安装在手机上

1

正如@zain发布之前你可以使用。

Intent intent = new Intent(Intent.ACTION_VIEW); 
intent.setData(Uri.parse("http://www.stackoverflow.com")); 
startActivity(intent); 

但是,如果你有多个浏览器安装在设备上,并希望从其中选择一个。使用目的选择器这样

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); 

从这里 Show browser list when opening a link in android

0

enter image description here

  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); 
参考
相关问题