安卓:识别为可与QUOT一个应用程序或活动;默认"可与、应用程序、QUOT

2023-09-12 22:28:41 作者:痞子伯爵、

当安装了多个浏览器,默认是没有设置的,我会选择器对话框,设置默认的可能性。

如何应用程序(或活性)制成本身识别的系统作为网页浏览器。 如果我做这样的事情:

 意向意图=新的意图(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
startActivity(Intent.createChooser(意向,TEST));
 

我会得到这些应用程序的列表:浏览器(谷歌),联系人,Gmail中,电话,但不是歌剧(微型)浏览器。因此,Opera有没有可浏览的类别,但仍拾起Android作为一个网页浏览器。这是如何工作的?

解决方案

 意向意图=新的意图(Intent.ACTION_VIEW);
intent.setData(Uri.parse(http://www.google.com));
startActivity(意向);
 
Android 设备上可以实现 3D Touch 吗 原力计划

将打开浏览器选择器,包括默认的复选框。该数据需要的东西的http:或https:开头 - 型

选择,当然在对话框中的项目将要开到指定URL的浏览器。这就是真正的情况在基地主页的应用程序时,点击浏览器图标时。

这是不是100%,我希望(100%将是一个开放的,而不要去网址浏览器),但可以接受。

When installed more than one Browser and the default is not set, I will get the chooser dialog with the possibility to set the default.

How does an application (or Activity) made itself recognizable by the system as a web browser. If I do something like this:

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
startActivity(Intent.createChooser(intent, "TEST"));

I'll get a list of the apps: Browser (google), Contacts, Gmail, Phone, but not the Opera (mini) browser. So, Opera has no category Browsable but is still picked up by Android as a web browser. How does this work?

解决方案

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

will bring up the browser chooser including the default checkbox. The data needs to be something of "http:" or "https:"-type.

Selecting an item in the dialog of course will open the browser going to the specified URL. And that is actually the case when at the base Home app when clicking to the browser icon.

This is not 100% what I hoped (100% would be open a browser without going to the URL), but acceptable.

 
精彩推荐
图片推荐