has Permissions Granted - Android Activity

Android examples for Activity:Activity Feature

Description

has Permissions Granted

Demo Code


import android.app.Activity;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;

public class Main {
  public static boolean hasPermissionsGranted(Activity context, String[] permissions) {
    for (String permission : permissions) {
      if (ActivityCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
        return false;
      }/*from   w w  w . jav a2 s. com*/
    }
    return true;
  }
}

Related Tutorials