安装多个搜索应用后,长按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;
}
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;
}