有没有办法在Android中强行打开一个链接在Chrome中打开? [英] Is there any way in Android to force open a link to open in Chrome?

查看:707
本文介绍了有没有办法在Android中强行打开一个链接在Chrome中打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在测试有很多jQuery的动画开发的web应用程序,我们已经通知确实表现不佳与内置的网络浏览器。在测试的浏览器,web应用程序的性能是令人难以置信的速度更快。我只是想知道是否有任何类型的脚本,将强制打开的链接在Chrome浏览器Android版,类似于它是如何iOS中完成的。

I'm currently testing a webapp developed with lots of Jquery animations, and we've notice really poor performance with the built-in web browser. While testing in Chrome, the performance of the webapp is unbelievably quicker. I'm just wondering if there was any type of script that would force open a link in Chrome for Android, similar to how it's done in iOS.

推荐答案

一个更优雅的方式来实现这一目标是使用 Intent.ACTION_VIEW 的意图是正常的,但加包 com.android.chrome 的意图。这个工程的Chrome浏览器是否为默认的浏览器,无论并且保证完全一样,如果用户已经从选择器列表中选择浏览器相同的行为。

A more elegant way to achieve this is to use the Intent.ACTION_VIEW intent as normal, but add the package com.android.chrome to the intent. This works regardless of whether Chrome is the default browser and ensures exactly the same behaviour as if the user had selected Chrome from the chooser list.

String urlString="http://mysuperwebsite";
Intent intent=new Intent(Intent.ACTION_VIEW,Uri.parse(urlString));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setPackage("com.android.chrome");
try {
    context.startActivity(intent);
} catch (ActivityNotFoundException ex) {
    // Chrome browser presumably not installed so allow user to choose instead
    intent.setPackage(null);
    context.startActivity(intent);
}

这篇关于有没有办法在Android中强行打开一个链接在Chrome中打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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