这是我的代码:
Intent i = (new Intent(Intent.ACTION_SEND, Uri.fromParts("sms", "12345678", null)));
PackageManager pm = getApplicationContext().getPackageManager();
final ResolveInfo mInfo = pm.resolveActivity(i, PackageManager.MATCH_DEFAULT_ONLY);
Log.i(TAG, "apk:"+mInfo.activityInfo.packageName);
我回来了:
apk:com.mysms.android.sms
无论默认应用程序是什么。
如果我进入设置并将默认应用程序切换到消息,我永远不会返回 com.android.sms(或任何消息包)。我特别需要 com.whatever.its.name 形式的默认消息应用程序。
更新:我放弃得太早了!如果其他人对此感兴趣,这对我有用:
String defApp = Settings.Secure.getString(getContentResolver(), "sms_default_application");
PackageManager pm = getApplicationContext().getPackageManager();
Intent iIntent = pm.getLaunchIntentForPackage(defApp);
ResolveInfo mInfo = pm.resolveActivity(iIntent,0);
Log.i(TAG, "apk:"+mInfo.activityInfo.packageName);