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.mobantica.DriverItRide.activities.ActivityLogin.java
@Override protected void onResume() { super.onResume(); if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CALL_PHONE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_PHONE_STATE }, 123);// w w w.ja v a 2s.c o m } else { if (mGoogleApiClient == null) { mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(LocationServices.API).build(); mGoogleApiClient.connect(); createLocationRequest(); } } }
From source file:co.taqat.call.CallActivity.java
private void refreshInCallActions() { if (!LinphonePreferences.instance().isVideoEnabled() || isConferenceRunning) { enabledVideoButton(false);// w ww. j a v a2s. c om } else { if (video.isEnabled()) { if (isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) { video.setImageResource(R.drawable.camera_selected); videoProgress.setVisibility(View.INVISIBLE); } else { video.setImageResource(R.drawable.camera_button); } } else { video.setImageResource(R.drawable.camera_button); } } if (getPackageManager().checkPermission(Manifest.permission.CAMERA, getPackageName()) != PackageManager.PERMISSION_GRANTED) { video.setImageResource(R.drawable.camera_button); } if (isSpeakerEnabled) { speaker.setImageResource(R.drawable.speaker_selected); } else { speaker.setImageResource(R.drawable.speaker_default); } if (getPackageManager().checkPermission(Manifest.permission.RECORD_AUDIO, getPackageName()) != PackageManager.PERMISSION_GRANTED) { isMicMuted = true; } if (isMicMuted) { micro.setImageResource(R.drawable.micro_selected); } else { micro.setImageResource(R.drawable.micro_default); } try { if (isSpeakerEnabled) { routeSpeaker.setImageResource(R.drawable.route_speaker_selected); routeEarpiece.setImageResource(R.drawable.route_earpiece); routeBluetooth.setImageResource(R.drawable.route_bluetooth); } routeSpeaker.setImageResource(R.drawable.route_speaker); if (BluetoothManager.getInstance().isUsingBluetoothAudioRoute()) { routeEarpiece.setImageResource(R.drawable.route_earpiece); routeBluetooth.setImageResource(R.drawable.route_bluetooth_selected); } else { routeEarpiece.setImageResource(R.drawable.route_earpiece_selected); routeBluetooth.setImageResource(R.drawable.route_bluetooth); } } catch (NullPointerException npe) { Log.e("Bluetooth: Audio routes menu disabled on tablets for now (4)"); } }
From source file:com.amazonaws.mobile.client.AWSMobileClient.java
/** * Uses Android system commands to determine if the device is online. * Requires ACCESS_NETWORK_STATE./*from w w w . j a va 2 s.c om*/ * * @param context application context * @return true if permission to access network state is granted and network is connected. */ protected boolean isNetworkAvailable(final Context context) { try { Class.forName("android.support.v4.content.ContextCompat"); int hasReadExternalStoragePermission = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_NETWORK_STATE); if (hasReadExternalStoragePermission != PackageManager.PERMISSION_GRANTED) { return false; } } catch (ClassNotFoundException e) { Log.w(TAG, "Could not check if ACCESS_NETWORK_STATE permission is available.", e); } try { ConnectivityManager manager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { return true; } } catch (Exception e) { Log.w(TAG, "Could not access network state", e); } return false; }
From source file:com.netease.qa.emmagee.service.EmmageeService.java
/** * Above JellyBean, we cannot grant READ_LOGS permission... * * @return/*from w ww . j av a 2s. com*/ */ private boolean isGrantedReadLogsPermission() { int permissionState = getPackageManager().checkPermission(android.Manifest.permission.READ_LOGS, getPackageName()); return permissionState == PackageManager.PERMISSION_GRANTED; }
From source file:com.aero2.android.DefaultActivities.SmogMapActivity.java
public void requestLocation() { mLocationRequest = LocationRequest.create(); mLocationRequest.setInterval(7000);//from w w w .java 2 s.c om mLocationRequest.setFastestInterval(7000); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); //if the user hasn't granted the app location permissions if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) { // Show an expanation 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. removeSplashScreen(); } else { // No explanation needed, we can request the permission. removeSplashScreen(); ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, MY_PERMISSIONS_REQUEST); // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an // app-defined int constant. The callback method gets the // result of the request. } return; } Log.v(LOG_TAG, "About to request Location"); LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this); Log.v(LOG_TAG, "Requested Location"); }
From source file:com.seatgeek.placesautocompletedemo.MainFragment.java
private void setUpMapIfNeeded() { // Do a null check to confirm that we have not already instantiated the map. // if (mMap == null) {//from w w w. j a v a 2s .com // Try to obtain the map from the SupportMapFragment. // mMap = mMapFragment.getMap(); // Check if we were successful in obtaining the map. if (mMap != null) { if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } mMap.setMyLocationEnabled(false); mMap.getUiSettings().setCompassEnabled(true); mMap.getUiSettings().setZoomControlsEnabled(false); mMap.getUiSettings().setMyLocationButtonEnabled(true); LatLng update = getLastKnownLocation(); if (mLocation != null) { // mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mLocation, 15)); mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLocation, 15f), 50, null); mLocationMarker = mMap.addMarker(new MarkerOptions().position(mLocation) .title(mapActivity.getResources().getString(R.string.marker_you)) .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_marker_me))); mLocationMarker.showInfoWindow(); } mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng latLng) { mIsNeedLocationUpdate = false; mLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); // moveToLocation(latLng, false); // if(mSlidingUpPanelLayout.isExpanded()) // mSlidingUpPanelLayout.collapsePane(); // else { // rlContent.setVisibility(View.GONE); //// edSearch.setVisibility(View.VISIBLE); // } } }); } } }
From source file:cl.gisred.android.MapsActivity.java
private void verifPermisos() { if (ContextCompat.checkSelfPermission(MapsActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(MapsActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)) { } else {//from w w w. jav a 2 s . co m // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(MapsActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, Util.REQUEST_ACCESS_FINE_LOCATION); } } else { initGeoposition(); } }
From source file:com.dvn.vindecoder.ui.user.GetAllVehicalDetails.java
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (requestCode == REQUEST_ACESS_STORAGE && grantResults[0] == PackageManager.PERMISSION_GRANTED) { startDilog();/*from w ww . j a v a 2s . com*/ } if (requestCode == REQUEST_ACESS_CAMERA && grantResults[0] == PackageManager.PERMISSION_GRANTED) { openCameraApplication(); } }
From source file:ch.uzh.supersede.feedbacklibrary.FeedbackActivity.java
@Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { switch (requestCode) { case PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Resources res = getResources(); if (userScreenshotChosenTask .equals(res.getString(R.string.supersede_feedbacklibrary_photo_capture_text))) { } else if (userScreenshotChosenTask .equals(res.getString(R.string.supersede_feedbacklibrary_library_chooser_text))) { galleryIntent();//from w ww.j a v a 2 s . c o m } } else { // The user denied the permission onRequestPermissionsResultDenied(requestCode, permissions, grantResults, Manifest.permission.READ_EXTERNAL_STORAGE, R.string.supersede_feedbacklibrary_external_storage_permission_text, getResources().getString( R.string.supersede_feedbacklibrary_external_storage_permission_text_instructions)); } break; case PERMISSIONS_REQUEST_RECORD_AUDIO: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Toast toast = Toast.makeText(getApplicationContext(), R.string.supersede_feedbacklibrary_record_audio_permission_granted_text, Toast.LENGTH_SHORT); toast.show(); } else { // The user denied the permission onRequestPermissionsResultDenied(requestCode, permissions, grantResults, Manifest.permission.RECORD_AUDIO, R.string.supersede_feedbacklibrary_record_audio_permission_text, getResources().getString( R.string.supersede_feedbacklibrary_record_audio_permission_text_instructions)); } break; } }
From source file:cl.gisred.android.LectorInspActivity.java
private void verifPermisos() { if (ContextCompat.checkSelfPermission(LectorInspActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(LectorInspActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)) { } else {/*from w w w . j a v a2s . c o m*/ // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(LectorInspActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, Util.REQUEST_ACCESS_FINE_LOCATION); } } else { initGeoposition(); } }