在Android中打开URL';从我的应用程序中删除web浏览器?
从我的应用程序在Android的web浏览器中打开URL? 我试过这个:在Android中打开URL';从我的应用程序中删除web浏览器?,android,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
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();
}
您应该检查链接,否则必须显示日志。您可以尝试以下操作:
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) {
}
}
你面临的问题是什么?你的logcat怎么说??
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) {
}
}