长按Home键启动默认的搜索应用
2016-05-18 09:29
239 查看
安装多个搜索应用后,长按Home键启动默认的搜索应用
如何设置默认的谷搜索应用?
修改frameworks/base/services/core/java/com/android/server/search/SearchManagerService.java的getAssistIntent方法
public ComponentName getAssistIntent(int userHandle) {
try {
userHandle = ActivityManager.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
userHandle, true, false, "getAssistIntent", null);
IPackageManager pm = AppGlobals.getPackageManager();
Intent assistGoogleIntent = new Intent(Intent.ACTION_ASSIST);
assistGoogleIntent.setPackage("com.google.android.googlequicksearchbox"); //默认搜索的包名
ResolveInfo info = pm.resolveIntent(assistGoogleIntent,
assistGoogleIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
PackageManager.MATCH_DEFAULT_ONLY, userHandle);
if (info != null) {
return new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name);
}
Intent assistIntent = new Intent(Intent.ACTION_ASSIST);
info = pm.resolveIntent(assistIntent, assistIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
PackageManager.MATCH_DEFAULT_ONLY, userHandle);
if (info != null) {
return new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name);
}
} catch (RemoteException re) {
// Local call
Log.e(TAG, "RemoteException in getAssistIntent: " + re);
} catch (Exception e) {
Log.e(TAG, "Exception in getAssistIntent: " + e);
}
return null;
}
如何设置默认的谷搜索应用?
修改frameworks/base/services/core/java/com/android/server/search/SearchManagerService.java的getAssistIntent方法
public ComponentName getAssistIntent(int userHandle) {
try {
userHandle = ActivityManager.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
userHandle, true, false, "getAssistIntent", null);
IPackageManager pm = AppGlobals.getPackageManager();
Intent assistGoogleIntent = new Intent(Intent.ACTION_ASSIST);
assistGoogleIntent.setPackage("com.google.android.googlequicksearchbox"); //默认搜索的包名
ResolveInfo info = pm.resolveIntent(assistGoogleIntent,
assistGoogleIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
PackageManager.MATCH_DEFAULT_ONLY, userHandle);
if (info != null) {
return new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name);
}
Intent assistIntent = new Intent(Intent.ACTION_ASSIST);
info = pm.resolveIntent(assistIntent, assistIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
PackageManager.MATCH_DEFAULT_ONLY, userHandle);
if (info != null) {
return new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name);
}
} catch (RemoteException re) {
// Local call
Log.e(TAG, "RemoteException in getAssistIntent: " + re);
} catch (Exception e) {
Log.e(TAG, "Exception in getAssistIntent: " + e);
}
return null;
}
相关文章推荐
- laravel 学习笔记——路由(中间件与路由组)
- 【MyBatis】Foreach语句
- 【Java提高】Java中是如何实现克隆
- 关于软件系统可靠性的几个9问题
- 极值问题
- 欢迎使用Markdown编辑器写博客
- text输入框改变事件
- C# 委托
- 系统吞吐量、TPS(QPS)、用户并发量、性能测试概念和公式
- laravel 学习笔记——路由(基础)
- windows下 在cmd 中 后台运行程序 关闭程序
- Android Intent最全面的解析
- View(视图)——ListView之 SimpleAdapter
- iOS学习--UIPickerView和UIDatePicker详解
- iOS深入学习(Block全面分析)
- [转]系统吞吐量(TPS)、用户并发量、性能测试概念和公式---学习
- ubuntu 14 系统的网络服务与此版本的网络管理器不兼容
- Android 判断imageview角度并旋转
- 最新可靠好用的DNS服务器地址汇总
- php常用函数集