Sunday, July 22, 2018

Unable to turn the silent mode in Gionee A1 programmatically

Leave a Comment

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; } 

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment