List of usage examples for android.content.pm PackageManager PERMISSION_GRANTED
int PERMISSION_GRANTED
To view the source code for android.content.pm PackageManager PERMISSION_GRANTED.
Click Source Link
From source file:com.alibaba.weex.extend.module.WXEventModule.java
@JSMethod(uiThread = true) public void openURL(String url) { if (TextUtils.isEmpty(url)) { return;/*from w ww .j ava 2 s. co m*/ } String scheme = Uri.parse(url).getScheme(); StringBuilder builder = new StringBuilder(); if ("weex://go/scan".equals(url)) { if (ContextCompat.checkSelfPermission(mWXSDKInstance.getContext(), Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.shouldShowRequestPermissionRationale((Activity) mWXSDKInstance.getContext(), Manifest.permission.CAMERA)) { Toast.makeText(mWXSDKInstance.getContext(), "Weex playground need the camera permission to scan QR code", Toast.LENGTH_SHORT) .show(); } else { ActivityCompat.requestPermissions((Activity) mWXSDKInstance.getContext(), new String[] { Manifest.permission.CAMERA }, CAMERA_PERMISSION_REQUEST_CODE); } } else { mWXSDKInstance.getContext() .startActivity(new Intent(mWXSDKInstance.getContext(), CaptureActivity.class)); } return; } if (TextUtils.equals("http", scheme) || TextUtils.equals("https", scheme) || TextUtils.equals("file", scheme)) { builder.append(url); } else { builder.append("http:"); builder.append(url); } Uri uri = Uri.parse(builder.toString()); Intent intent = new Intent(mWXSDKInstance.getContext(), WXPageActivity.class); intent.setAction(WEEX_ACTION); intent.setData(uri); intent.addCategory(WEEX_CATEGORY); mWXSDKInstance.getContext().startActivity(intent); if (mWXSDKInstance.checkModuleEventRegistered("event", this)) { HashMap<String, Object> params = new HashMap<>(); params.put("param1", "param1"); params.put("param2", "param2"); params.put("param3", "param3"); mWXSDKInstance.fireModuleEvent("event", this, params); } }
From source file:com.facebook.stetho.server.SecureHttpRequestHandler.java
private static void enforcePermission(Context context, LocalSocket peer) throws IOException, PeerAuthorizationException { Credentials credentials = peer.getPeerCredentials(); int uid = credentials.getUid(); int pid = credentials.getPid(); if (LogUtil.isLoggable(Log.VERBOSE)) { LogUtil.v("Got request from uid=%d, pid=%d", uid, pid); }// w w w.j a v a2 s . c o m String requiredPermission = Manifest.permission.DUMP; int checkResult = context.checkPermission(requiredPermission, pid, uid); if (checkResult != PackageManager.PERMISSION_GRANTED) { throw new PeerAuthorizationException( "Peer pid=" + pid + ", uid=" + uid + " does not have " + requiredPermission); } }
From source file:com.aitorvs.android.fingerlock.FingerLockApi23.java
@Override public boolean isFingerprintAuthSupported() { invalidContext();//from w ww. ja v a 2 s . c o m // check permissions int granted = ContextCompat.checkSelfPermission(mContext, android.Manifest.permission.USE_FINGERPRINT); if (granted != PackageManager.PERMISSION_GRANTED) { // not granted return false; } // return hardware support //noinspection MissingPermission return mFingerprintManager != null && mFingerprintManager.isHardwareDetected() && mFingerprintManager.hasEnrolledFingerprints(); }
From source file:br.com.anteros.android.persistence.backup.ImportDatabaseTask.java
@Override protected String doInBackground(final Void... args) { if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(activity, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { throw new BackupException( "No foi possvel executar a tarefa de importar o banco de dados pois voc no possu permisso para isto. Verifique se solicitou permisso no manifesto ou requisitou a permisso caso esteja usando Android(Marshmallow) 6 ou acima."); }//from w ww . j av a2s.c o m try { session.close(); } catch (Exception e1) { e1.printStackTrace(); } File dbBackupFile = importDatabaseFile; if (!dbBackupFile.exists()) { return "Arquivo de backup no foi encontrado. No foi possvel importar."; } else if (!dbBackupFile.canRead()) { return "Arquivo de backup no pode ser lido. No foi possvel importar."; } File dbFile = new File(databaseName); if (dbFile.exists()) { dbFile.delete(); } try { AndroidFileUtils.copyFile(dbBackupFile, dbFile); return "OK"; } catch (IOException e) { e.printStackTrace(); return e.getMessage(); } }
From source file:in.codehex.arrow.LoginActivity.java
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int grantResults[]) { switch (requestCode) { case Config.PERMISSION_READ_PHONE_STATE: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { imei = telephonyManager.getDeviceId(); } else {/*from w w w . j av a 2 s.co m*/ Toast.makeText(this, "Permission request denied", Toast.LENGTH_SHORT).show(); } break; } }
From source file:com.aitorvs.android.allowme.AllowMe.java
/** * Checks whether a particular permissions is already granted * * @param permission permission//from w w w . j a v a 2 s . com * @return <code>boolean</code> value, <code>true</code> when permissions is already granted, * <code>false</code> when permissions not granted. */ public static boolean isPermissionGranted(@NonNull String permission) { return ContextCompat.checkSelfPermission(safeActivity(), permission) == PackageManager.PERMISSION_GRANTED; }
From source file:MainActivity.java
@Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case REQUEST_PERMISSION_SEND_SMS: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Toast.makeText(MainActivity.this, "Permission Granted!", Toast.LENGTH_SHORT).show(); } else {/*from ww w. j a v a 2 s. co m*/ Toast.makeText(MainActivity.this, "Permission Denied!", Toast.LENGTH_SHORT).show(); } return; } } }
From source file:co.iyubinest.reddittop.data.preview.GlideMediaStoreRepo.java
@SuppressLint("NewApi") private boolean checkPermission() { return ContextCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; }
From source file:cn.jarlen.mediaplayer.sample.application.AppActivity.java
@Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { // permission was granted, yay! Do the task you need to do. } else {//from w ww . ja v a 2 s . c o m // permission denied, boo! Disable the functionality that depends on this permission. } } } }