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.github.akinaru.hcidebugger.activity.HciDebuggerActivity.java
/** * start bluetooth scan (launch from menu or when bluetooth is activated if previous start scan was launched) *///from w w w. j a v a2 s . com private void startScan() { mScanning = true; if (mScanType == ScanType.CLASSIC_SCAN) { if (mBluetoothAdapter.isDiscovering()) { mBluetoothAdapter.cancelDiscovery(); } mBluetoothAdapter.startDiscovery(); } else { if (Build.VERSION.SDK_INT >= 23) { if (checkSelfPermission( Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[] { Manifest.permission.ACCESS_COARSE_LOCATION }, REQUEST_PERMISSION_COARSE_LOCATION); return; } else { startBleScan(); } } } startScanSetup(); }
From source file:in.codehex.arrow.MainActivity.java
/** * start receiving location updates/* w w w. j a va 2 s. c o m*/ */ private void startLocationUpdates() { // marshmallow runtime location permission if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this); } else if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { android.Manifest.permission.ACCESS_FINE_LOCATION }, Config.PERMISSION_ACCESS_FINE_LOCATION); } }
From source file:com.almalence.opencam.ApplicationScreen.java
@TargetApi(23) protected void checkCameraPermission() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { cameraPermissionGranted = false; // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) { // Show an explanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. showRationaly(Manifest.permission.CAMERA); } else {// w ww .j ava 2s . co m // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA }, ApplicationScreen.CAMERA_PERMISSION_CODE); } } else cameraPermissionGranted = true; }
From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java
@Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { switch (requestCode) { case PERMISSION_REQUEST_COARSE_LOCATION: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { mWiz.requestBeaconRegions(mService); }//from w w w . jav a 2 s . co m mWiz.proceedToNextPage(); break; case PERMISSION_REQUEST_GET_ACCOUNTS: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { configureEmailAutoComplete(true); } break; default: super.onRequestPermissionsResult(requestCode, permissions, grantResults); break; } }
From source file:com.zertinteractive.wallpaper.MainActivity.java
@SuppressWarnings("NewApi") public void checkWriteExternalPermission() { int res = checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE); if (res != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, REQUEST_CODE_ASK_PERMISSIONS); }/*from w ww . j a va 2 s.c o m*/ }
From source file:com.almalence.opencam.ApplicationScreen.java
@TargetApi(23) public void checkLocationPermission() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { locationPermissionGranted = false; // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION) || ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_COARSE_LOCATION)) { // Show an explanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. showRationaly(Manifest.permission.ACCESS_FINE_LOCATION); } else {/*from w w w. j ava 2 s.c om*/ // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION }, ApplicationScreen.LOCATION_PERMISSION_CODE); } } else locationPermissionGranted = true; }
From source file:com.mobantica.DriverItRide.activities.ActivityLogin.java
private void startLocationUpdates() { if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling return;/*from w w w . j a v a2s .c o m*/ } LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this); }
From source file:cl.gisred.android.CatastroActivity.java
private void verifPermisos() { if (ContextCompat.checkSelfPermission(CatastroActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(CatastroActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)) { } else {//from ww w.j av a2s .co m // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(CatastroActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, Util.REQUEST_ACCESS_FINE_LOCATION); } } else { initGeoposition(); } }
From source file:cl.gisred.android.MantCatastroActivity.java
private void verifPermisos() { if (ContextCompat.checkSelfPermission(MantCatastroActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(MantCatastroActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)) { } else {/*from w ww .java 2s .co m*/ // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(MantCatastroActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, Util.REQUEST_ACCESS_FINE_LOCATION); } } else { initGeoposition(); } }
From source file:cl.gisred.android.OtRouteActivity.java
private void verifPermisos() { if (ContextCompat.checkSelfPermission(OtRouteActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(OtRouteActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)) { } else {/* w w w .j a v a 2 s . co m*/ // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(OtRouteActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, Util.REQUEST_ACCESS_FINE_LOCATION); } } else { initGeoposition(); } }