且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

设置默认浏览器编程活动

更新时间:2023-11-27 21:17:28

是的,因为这可以迫使你的应用程序始终开放原生的Andr​​oid浏览器只。为此,您必须确定启动活动浏览器应用程序,这样的事情:

Yes, for this you can force your application to always open native android browser only. For this you have to identify the launching Activity of Browser application, something like this:

Intent intent = new Intent();
intent.setComponent(new ComponentName("com.google.android.browser","com.google.android.browser.BrowserActivity"));
intent.setAction("android.intent.action.VIEW");
intent.addCategory("android.intent.category.BROWSABLE");
Uri uri = Uri.parse(url);
intent.setData(uri);
try
{
    startActivity(intent);
}
catch (Exception e)
{
   e.printStackTrace();
}