Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.content.pm.PackageManager; public class Main { static Context collectUtilContext; /** * @param context * @return Boolean * @throws * @Title: checkPhoneState * @Description: TODO */ private static Boolean checkPhoneState(Context context) { PackageManager pm = context.getPackageManager(); if (pm.checkPermission("android.permission.READ_PHONE_STATE", context.getPackageName()) != 0) { return false; } return true; } /** * @param context * @param permission * @return boolean * @Title: checkPermission * @Description: TODO */ public static boolean checkPermission(Context context, String permission) { collectUtilContext = context; PackageManager pm = context.getPackageManager(); return pm.checkPermission(permission, collectUtilContext.getPackageName()) == PackageManager.PERMISSION_GRANTED; } }