从我的应用程序在Android的Web浏览器中打开URL?

时间:2015-07-06 07:47:03

标签: android

从我的应用程序在Android的Web浏览器中打开URL? 我试过这个:

 try {
        Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(download_link));
        startActivity(myIntent);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(this, "No application can handle this request."
            + " Please install a webbrowser",  Toast.LENGTH_LONG).show();
        e.printStackTrace();
    }

2 个答案:

答案 0 :(得分:0)

Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                Uri.parse(playStoreLink));
        startActivity(browserIntent);

你应该检查你的链接,否则你必须出示你的记录。

答案 1 :(得分:0)

您可以尝试以下操作:

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

public void onOpenWebBrowser(View v)
{
   Intent webPageIntent = new Intent(Intent.ACTION_VIEW);
   webPageIntent.setData(Uri.parse("https://www.google.co.in/"));

   try {
      startActivity(webPageIntent);
   } catch (ActivityNotFoundException ex) {

   }
}