Android 获取拨号程序包名称

Android get dialer package name

我需要获取 post 关于未接来电通知的应用程序包名称。据我了解,它使设备成为拨号器应用程序。我可以在设备上获取拨号器应用程序的包名称吗,我需要它来自 API 19?

您可以使用 Intent.ACTION_DIAL action and PackageManager.queryIntentActivities(...). Where it will return list of applications which can dial phone. Read more at

过滤所有拨号程序

您可以直接使用下面的代码

public List<String> getPackagesOfDialerApps(Context context){

    List<String> packageNames = new ArrayList<>();

    // Declare action which target application listen to initiate phone call
    final Intent intent = new Intent();
    intent.setAction(Intent.ACTION_DIAL);
    // Query for all those applications
    List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentActivities(intent, 0);
    // Read package name of all those applications
    for(ResolveInfo resolveInfo : resolveInfos){
        ActivityInfo activityInfo = resolveInfo.activityInfo;
        packageNames.add(activityInfo.applicationInfo.packageName);
    }

    return packageNames;
}

要获取应用程序包(和 activity 名称),您可以使用 adb 命令。

启动应用程序,然后:

adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'

来自输出:

mFocusedApp=AppWindowToken{
  e224f9d token=Token{
    d8b2e74 ActivityRecord{
      1d97647 u0 com.android.dialer/.app.DialtactsActivity t1078
    }
  }
}

您可以说应用程序包是 com.android.dialer 并且 activity 名称是 .app.DialtactsActivity