如何设置我的谷歌浏览器作为应用程序的默认浏览器,我做编程 [英] How can i set the Google Chrome as a default browser of the application that i make programmatically

查看:346
本文介绍了如何设置我的谷歌浏览器作为应用程序的默认浏览器,我做编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能,我们可以设置谷歌Chrome为默认浏览器?因为我知道,在Android 4.2的没有在使用Android通用浏览器,他们将其更改为谷歌浏览器。就像低于这个code。

Is it possible that we can set the Google chrome as the default browser? because i learned that in android 4.2 their is no more generic browser in android they change it to Google Chrome. Just like this code below.

Intent intent= new Intent();        
intent.setAction("android.intent.action.VIEW");    
Uri content_url = Uri.parse("http://www.eltosystem.com");   
intent.setData(content_url);
intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");   
                        startActivity(intent); 

有没有可能我们改变code将谷歌Chrome作为默认?
提前致谢。 :)

Is it possible that we change the code to set the Google Chrome as a default? Thanks in advance. :)

推荐答案

不要在意图设置类名。如果只有一个应用程序处理该URL,这个程序将启动。如果有一个以上的应用程序,并且用户尚未选择一个缺省的是,这将提示用户。如果用户选中了一个已经,这将启动用户preferred之一。它总是一个好主意,让用户选择他们要使用的浏览器。它可能会证明,Chrome的简单了,没有为他们工作的任何原因;例如,用户可能需要使用特殊的浏览器由于特定的残疾。

Do not set class name on the intent. If there is only one app that handles that url, this app will be started. If there are more than one apps, and the user has not chosen a default one yet, this will prompt the user. If the user has chosen one already, this will start the user preferred one. It's always a good idea to let the user choose which browser they want to use. It might turn out that Chrome plain does not work for them for any number of reasons; for example the user might need to use special browser due to specific disability.

如果您想要明确地推出谷歌Chrome,你必须找到自己的包名( com.android.chrome :-))和活性处理在 android.intent.action.VIEW 的行动。您可以从谷歌浏览器清单,它存储在它的apk文件找到。您将需要从已安装它是一个设备中提取这一点。

If you still want to explicitly launch Google Chrome, you'll have to find its package name (com.android.chrome :-)) and the activity that handles the android.intent.action.VIEW action. You can find this from the Google Chrome manifest, which is stored in it's .apk. You will need to extract this from a device that has it installed.

不过请注意,是有保证为零,谷歌Chrome将是设备上present,即使设备运行的是JB 4.2。 OEM厂商有自由(在一定程度上)自定义安装在设备上的包的列表,所以即使标准4.2 GMS图像包括铬,三星例如仍然可能会决定将其删除。更何况,根据4.2 AOSP设备将可能永远不会有浏览器,因为它不是开源的Andr​​oid平台的一部分,并且用户无法从谷歌下载Play商店,因为那一个也不是AOSP的一部分。 (我故意驳回基于AOSP的设备,其中包括谷歌播放,谷歌地图和Chrome在它的图像没有适当的GMS许可证的情况下)

Note however, that there is zero guarantee that Google Chrome will be present on the device, even if the device is running JB 4.2. OEMs have freedom (to a certain degree) to customize the list of packages installed on the device, so even if the standard 4.2 GMS image includes Chrome, Samsung for example might still decide to remove it. Not to mention that devices based on 4.2 AOSP will likely never have Chrome, as it is not part of the open source Android platform, and users can't download it from Google Play Store, as that one is also not part of AOSP. (I am intentionally dismissing the scenario of AOSP-based device that includes Google Play, Google Maps, and Chrome in its image without proper GMS license)

这篇关于如何设置我的谷歌浏览器作为应用程序的默认浏览器,我做编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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