android 下载默认启动QQ浏览器
来源:互联网 发布:钢琴 王雅伦 知乎 编辑:程序博客网 时间:2024/04/29 15:35
//内置QQ浏览器
//在程序启动的第一个activity 中添加如下函数
//设置系统默认浏览器是QQ浏览器
private void setBroser(){
PackageManager packageManager = this.getPackageManager();
String str1 = "android.intent.category.DEFAULT";
String str2 = "android.intent.category.BROWSABLE";
String str3 = "android.intent.action.VIEW";
// 设置默认项的必须参数之一,用户的操作符合该过滤器时,默认设置起效
IntentFilter filter = new IntentFilter(str3);
filter.addCategory(str1);
filter.addCategory(str2);
filter.addDataScheme("http");
// 关键 设置QQ浏览:包名:com.tencent.mtt ,类名:com.tencent.mtt.MainActivity
ComponentName component = new ComponentName("com.tencent.mtt",
"com.tencent.mtt.MainActivity");
Intent intent = new Intent(str3);
intent.addCategory(str2);
intent.addCategory(str1);
Uri uri = Uri.parse("http://");
intent.setDataAndType(uri, null);
// 找出手机当前安装的所有浏览器程序
List<ResolveInfo> resolveInfoList = packageManager
.queryIntentActivities(intent,
PackageManager.GET_INTENT_FILTERS);
int size = resolveInfoList.size();
ComponentName[] arrayOfComponentName = new ComponentName[size];
for (int i = 0; i < size; i++) {
ActivityInfo activityInfo = resolveInfoList.get(i).activityInfo;
String packageName = activityInfo.packageName;
String className = activityInfo.name;
// 清除之前的默认设置
packageManager.clearPackagePreferredActivities(packageName);
ComponentName componentName = new ComponentName(packageName,
className);
arrayOfComponentName[i] = componentName;
}
packageManager.addPreferredActivity(filter,
IntentFilter.MATCH_CATEGORY_SCHEME, arrayOfComponentName,
component);
}
//调用
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setBroser();//调用函数
}
//在程序启动的第一个activity 中添加如下函数
//设置系统默认浏览器是QQ浏览器
private void setBroser(){
PackageManager packageManager = this.getPackageManager();
String str1 = "android.intent.category.DEFAULT";
String str2 = "android.intent.category.BROWSABLE";
String str3 = "android.intent.action.VIEW";
// 设置默认项的必须参数之一,用户的操作符合该过滤器时,默认设置起效
IntentFilter filter = new IntentFilter(str3);
filter.addCategory(str1);
filter.addCategory(str2);
filter.addDataScheme("http");
// 关键 设置QQ浏览:包名:com.tencent.mtt ,类名:com.tencent.mtt.MainActivity
ComponentName component = new ComponentName("com.tencent.mtt",
"com.tencent.mtt.MainActivity");
Intent intent = new Intent(str3);
intent.addCategory(str2);
intent.addCategory(str1);
Uri uri = Uri.parse("http://");
intent.setDataAndType(uri, null);
// 找出手机当前安装的所有浏览器程序
List<ResolveInfo> resolveInfoList = packageManager
.queryIntentActivities(intent,
PackageManager.GET_INTENT_FILTERS);
int size = resolveInfoList.size();
ComponentName[] arrayOfComponentName = new ComponentName[size];
for (int i = 0; i < size; i++) {
ActivityInfo activityInfo = resolveInfoList.get(i).activityInfo;
String packageName = activityInfo.packageName;
String className = activityInfo.name;
// 清除之前的默认设置
packageManager.clearPackagePreferredActivities(packageName);
ComponentName componentName = new ComponentName(packageName,
className);
arrayOfComponentName[i] = componentName;
}
packageManager.addPreferredActivity(filter,
IntentFilter.MATCH_CATEGORY_SCHEME, arrayOfComponentName,
component);
}
//调用
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setBroser();//调用函数
}
0 0
- android 下载默认启动QQ浏览器
- 启动android默认浏览器
- 启动android默认浏览器
- 启动android默认浏览器
- 启动android默认浏览器
- 启动android默认浏览器
- 启动android默认浏览器
- android启动默认浏览器
- Android开发之启动android默认浏览器
- 打开URL启动android默认浏览器,启动指定浏览器
- 打开URL启动android默认浏览器,启动指定浏览器
- 使用URL启动android默认浏览器,启动指定浏览器
- 打开URL启动android默认浏览器,启动指定浏览器
- 【web browser】启动android默认浏览器
- java 启动默认浏览器
- C++ 启动默认浏览器
- android实现程序启动直接调用系统默认浏览器
- Myeclipse修改默认启动浏览器
- Git: Removing commits on remote
- 矩阵的坐标变换(转)
- 又拍网架构中的数据库分库设计
- android - cocos2dx调用java函数
- Leetcode: Add Two Numbers
- android 下载默认启动QQ浏览器
- 2015年2月份,世界足联最新排名
- 图片加时间戳
- 程序之路,褪去浮躁
- iScroll4.2.5中的无法滑动或点击的解决方案
- libevent多线程编程实例
- test dword ptr [eax],eax ; probe page.调试中断解决方案
- iOS:编译错误 PBXCp Error
- 跟着CC学设计模式系列