check Permissions via Context - Android android.content

Android examples for android.content:Context

Description

check Permissions via Context

Demo Code

import android.content.Context;
import android.content.pm.PackageManager;

public class Main {

  public static boolean checkPermissions(Context context, String permission) {
    PackageManager localPackageManager = context.getPackageManager();
    return localPackageManager.checkPermission(permission,
        context.getPackageName()) == PackageManager.PERMISSION_GRANTED;
  }//from  w w  w .  j a v  a2s.c  om

}

Related Tutorials