Android O获取google短信的通知铃声

android.app.INotificationManager sINM = android.app.INotificationManager.Stub.asInterface(android.os.ServiceManager.getService(Context.NOTIFICATION_SERVICE));
String pkg = "com.google.android.apps.messaging";
int uid = getApplicationContext().getPackageManager().getPackageUid(pkg, 0);
String channelId = "bugle_default_channel";// check from /data/system/notification_policy.xml
android.media.RingtoneManager.getRingtone(getApplicationContext(), sINM.getNotificationChannelForPackage(pkg, uid, channelId, true).getSound()).play();

需要在 CellBroadcastReceiver 的 Android.mk 文件中添加 INotificationManager.aidl
LOCAL_SRC_FILES += src/android/app/INotificationManager.aidl

猜你喜欢

转载自blog.csdn.net/zhangqi6627/article/details/107685789