Hey there I am using below code to turn the device into silence mode.
public static void setDeviceOnSilent(Context context) {
AudioManager audioManager = (AudioManager) context.getSystemService(AUDIO_SERVICE);
audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
}
The above code work well in all device except Gionee A1. Please suggest what is the problem i already given the NotificationAccessPolicyEnabled Permission. below is the code.
public static boolean isNotificationAccessPolicyEnabled(Context context) {
NotificationManager notificationManager;
notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
&& !notificationManager.isNotificationPolicyAccessGranted()) {
Intent intent = new Intent(
android.provider.Settings
.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
context.startActivity(intent);
return false;
}
return true;
}
from Unable to turn the silent mode in Gionee A1 programmatically
No comments:
Post a Comment