您的位置:首页 > 其它

长按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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: