安卓:识别为可与QUOT一个应用程序或活动;默认" [英] Android: recognized as an App or Activity that can be made "default"

查看:105
本文介绍了安卓:识别为可与QUOT一个应用程序或活动;默认"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

 意向意图=新的意图(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(意向);
 

将打开浏览器选择器,包括默认的复选框。该数据需要的东西的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.

这篇关于安卓:识别为可与QUOT一个应用程序或活动;默认"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆