List of usage examples for android.content Context checkCallingOrSelfPermission
@CheckResult(suggest = "#enforceCallingOrSelfPermission(String,String)") @PackageManager.PermissionResult public abstract int checkCallingOrSelfPermission(@NonNull String permission);
From source file:com.squareup.picasso3.Utils.java
static boolean hasPermission(Context context, String permission) { return context.checkCallingOrSelfPermission(permission) == PackageManager.PERMISSION_GRANTED; }
From source file:com.onesignal.TrackGooglePurchase.java
static boolean CanTrack(Context context) { if (iapEnabled == -99) iapEnabled = context.checkCallingOrSelfPermission("com.android.vending.BILLING"); try {/*from w w w . j a va2s . co m*/ if (iapEnabled == PackageManager.PERMISSION_GRANTED) IInAppBillingServiceClass = Class.forName("com.android.vending.billing.IInAppBillingService"); } catch (Throwable t) { iapEnabled = 0; return false; } return (iapEnabled == PackageManager.PERMISSION_GRANTED); }
From source file:com.wiyun.engine.network.Network.java
static boolean isWifiConnected() { Context context = Director.getInstance().getContext(); if (context.checkCallingOrSelfPermission( android.Manifest.permission.ACCESS_WIFI_STATE) == PackageManager.PERMISSION_GRANTED) { WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (wm != null) { WifiInfo info = wm.getConnectionInfo(); return info != null && info.getSupplicantState() == SupplicantState.COMPLETED; } else {//from w w w.j av a 2 s .co m return false; } } else { Log.w("libwiengine", "you need add ACCESS_WIFI_STATE permission"); return false; } }
From source file:com.segment.analytics.internal.Utils.java
/** Returns true if the application has the given permission. */ public static boolean hasPermission(Context context, String permission) { return context.checkCallingOrSelfPermission(permission) == PERMISSION_GRANTED; }
From source file:com.mikimedia.android.component.PicassoHandle.java
private static void checkPermissionsOrThrowException(Context context) { String[] permissions = new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE, android.Manifest.permission.INTERNET, android.Manifest.permission.ACCESS_NETWORK_STATE }; for (String permission : permissions) { int result = context.checkCallingOrSelfPermission(permission); if (result != PackageManager.PERMISSION_GRANTED) { throw new RuntimeException("Error: PicassoHandle permissions required: " + permission); }//from w w w .j a va 2s.c om } }
From source file:com.pavlospt.rxfile.RxFile.java
private static boolean checkWriteExternalPermission(Context context) { int res = context.checkCallingOrSelfPermission(Constants.WRITE_EXTERNAL_PERMISSION); return (res == PackageManager.PERMISSION_GRANTED); }
From source file:com.apptentive.android.sdk.util.Util.java
public static boolean hasPermission(Context context, final String permission) { if (context == null) { return false; }//from w w w.j a va 2s .c o m int perm = context.checkCallingOrSelfPermission(permission); return perm == PackageManager.PERMISSION_GRANTED; }
From source file:com.gm.goldencity.util.Utils.java
/** * Checking read sms permission/*from w ww . j a v a2 s . c om*/ * * @param context Application context * @return */ public static boolean checkReadSMSPermission(Context context) { String permission = "android.permission.READ_SMS"; int res = context.checkCallingOrSelfPermission(permission); return (res == PackageManager.PERMISSION_GRANTED); }
From source file:com.gm.goldencity.util.Utils.java
/** * Checking write sms permission/*from w ww . j av a2 s .co m*/ * * @param context Application context * @return */ public static boolean checkWriteSMSPermission(Context context) { String permission = "android.permission.WRITE_SMS"; int res = context.checkCallingOrSelfPermission(permission); return (res == PackageManager.PERMISSION_GRANTED); }
From source file:com.gm.goldencity.util.Utils.java
/** * Checking install package permission/*from w w w .j a v a 2 s .c o m*/ * * @param context Application context * @return */ public static boolean checkInstallPackagesPermission(Context context) { String permission = "android.permission.INSTALL_PACKAGES"; int res = context.checkCallingOrSelfPermission(permission); return (res == PackageManager.PERMISSION_GRANTED); }