user8430 user8430 - 2 months ago 35
Android Question

How to get default device assistance app in android by code?

my phone installed two voice searches: google app and S-voice app. The default app is S-voice app as figure bellow. My question is that how can we get the default voice application using programmingcally in Android 6.0. Thank you in advance

enter image description here

This is what I did

private boolean isMyAppLauncherDefault(String myPackageName) {
final IntentFilter filter = new IntentFilter(Intent.ACTION_MAIN);

List<IntentFilter> filters = new ArrayList<IntentFilter>();
List<ComponentName> activities = new ArrayList<ComponentName>();
final PackageManager packageManager = (PackageManager) getPackageManager();

packageManager.getPreferredActivities(filters, activities, null);
for (ComponentName activity : activities) {

Log.d(TAG,"======packet default:==="+activity.getPackageName());
for (ComponentName activity : activities) {

if (myPackageName.equals(activity.getPackageName())) {
return true;
return false;

The above function is alway return true when my input is
. In other hands, the default app always returns
(indicates google voice)


Try this.

startActivity(new Intent(Intent.ACTION_VOICE_COMMAND).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));