通过代码的方式的话就不用手动去允许权限,后台默认去操作,用户界面无任何感知
1、应用通知权限
INotificationManager sINM = INotificationManager.Stub.asInterface(
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
public void setNotificationsEnabled(Context context,String packageName,boolean enable){
sINM.setNotificationsEnabledForPackage(
packageName,
getUid(context, packageName),
enable
);
}
public int getUid(Context context, String packageName) {
try {
PackageManager packageManager = context.getPackageManager();
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, 0);
return applicationInfo.uid;
} catch (Exception e) {
e.printSta