本文整理汇总了Java中com.karumi.dexter.listener.PermissionRequest类的典型用法代码示例。如果您正苦于以下问题:Java PermissionRequest类的具体用法?Java PermissionRequest怎么用?Java PermissionRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PermissionRequest类属于com.karumi.dexter.listener包,在下文中一共展示了PermissionRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkCameraPermission
import com.karumi.dexter.listener.PermissionRequest; //导入依赖的package包/类
private void checkCameraPermission() {
Dexter.withActivity(this)
.withPermissions(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE)
.withListener(new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport report) {
if (report.areAllPermissionsGranted()) {
// Do something
} else {
Toast.makeText(MainActivity.this, R.string.camera_and_write_external_storage_denied, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> permissions, PermissionToken token) {
token.continuePermissionRequest();
}
})
.check();
}
示例2: checkPermissions
import com.karumi.dexter.listener.PermissionRequest; //导入依赖的package包/类
private void checkPermissions() {
Logger.getInstance().Debug(TAG, "checkPermissions");
Dexter.withActivity(this)
.withPermissions(PERMISSIONS_TO_REQUEST)
.withListener(new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport report) {
if (report.areAllPermissionsGranted()) {
Toasty.success(BootActivity.this, "All permissions granted! Thanks!", Toast.LENGTH_LONG).show();
}
_checkPermissionsFinished = true;
checkNavigateToMain();
}
@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> permissions, PermissionToken token) {
}
}).check();
}
示例3: checkCameraPermission
import com.karumi.dexter.listener.PermissionRequest; //导入依赖的package包/类
private void checkCameraPermission(){
Dexter.withActivity(this)
.withPermissions(
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.CAMERA
).withListener(new MultiplePermissionsListener() {
@Override public void onPermissionsChecked(MultiplePermissionsReport report) {
if(report.areAllPermissionsGranted()){
Intent intent = new Intent(NurseRecordActivity.this, CameraActivity.class);
startActivityForResult(intent, UPDATE_PHOTO);
}else{
showNeedPermissionDialog();
}
}
@Override public void onPermissionRationaleShouldBeShown(List<PermissionRequest> permissions, PermissionToken token) {
showNeedPermissionDialog();
}
}).check();
}
示例4: handleDeniedPermissions
import com.karumi.dexter.listener.PermissionRequest; //导入依赖的package包/类
private void handleDeniedPermissions(Collection<String> permissions) {
if (permissions.isEmpty()) {
return;
}
List<PermissionRequest> shouldShowRequestRationalePermissions = new LinkedList<>();
for (String permission : permissions) {
if (androidPermissionService.shouldShowRequestPermissionRationale(activity, permission)) {
shouldShowRequestRationalePermissions.add(new PermissionRequest(permission));
}
}
if (shouldShowRequestRationalePermissions.isEmpty()) {
requestPermissionsToSystem(permissions);
} else if (!rationaleAccepted.get()) {
PermissionRationaleToken permissionToken = new PermissionRationaleToken(this);
listener.onPermissionRationaleShouldBeShown(shouldShowRequestRationalePermissions,
permissionToken);
}
}
示例5: getPermissionDeniedFeedbackMethodIsCalledForShowingToastOnActivityContextNull
import com.karumi.dexter.listener.PermissionRequest; //导入依赖的package包/类
@Test
public void getPermissionDeniedFeedbackMethodIsCalledForShowingToastOnActivityContextNull(){
DummyPermissionListenerImplementation dummyPermissionListenerImplementation =
new DummyPermissionListenerImplementation(contextProvider, stubString);
setUpActivityContextNullButApplicationNotNullScenario();
try {
dummyPermissionListenerImplementation.onPermissionDenied(
new PermissionDeniedResponse(new PermissionRequest("Test"), true));
}catch (NullPointerException n){
}
verify(stubString).getPermissionDeniedFeedback();
}
示例6: rationaleTextMethodsAreCalledOnNotNullActivityContext
import com.karumi.dexter.listener.PermissionRequest; //导入依赖的package包/类
@Test public void rationaleTextMethodsAreCalledOnNotNullActivityContext() {
DummyPermissionListenerImplementation dummyPermissionListenerImplementation =
new DummyPermissionListenerImplementation(contextProvider, stubString);
setUpActivityContextInitializedScenario();
try {
dummyPermissionListenerImplementation.onPermissionRationaleShouldBeShown(
new PermissionRequest("Test"), permissionToken);
}catch (NullPointerException npe){
}
verify(stubString).getPermissionRationaleMessage();
verify(stubString).getPermissionRationaleTitle();
}
示例7: onPermissionRationaleShouldBeShown
import com.karumi.dexter.listener.PermissionRequest; //导入依赖的package包/类
@Override
public void onPermissionRationaleShouldBeShown(final PermissionRequest permission,
final PermissionToken token) {
handler.post(new Runnable() {
@Override
public void run() {
MADBikeBackgroundPermissionListener.super.onPermissionRationaleShouldBeShown(
permission, token);
}
});
}
示例8: onCreateView
import com.karumi.dexter.listener.PermissionRequest; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_sos, container, false);
ButterKnife.bind(this, view);
sharedPreferences = getActivity().getSharedPreferences("Profile", MODE_PRIVATE);
Dexter.checkPermissions(new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport report) {/* ... */}
@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> permissions, PermissionToken token) {/* ... */}
}, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION);
LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new MyLocationListener();
try {
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 10, locationListener);
else
Toast.makeText(getContext(), "Enable location services", Toast.LENGTH_SHORT).show();
} catch (SecurityException e) {
Log.e("locationListener", e.toString());
}
return view;
}
示例9: request
import com.karumi.dexter.listener.PermissionRequest; //导入依赖的package包/类
public static void request(Activity activity) {
Dexter.withActivity(activity)
.withPermissions(
Manifest.permission.CAMERA
).withListener(new MultiplePermissionsListener() {
@Override public void onPermissionsChecked(MultiplePermissionsReport report) {}
@Override public void onPermissionRationaleShouldBeShown(List<PermissionRequest> permissions, PermissionToken token) {}
}).check();
}
示例10: configureDexterListeners
import com.karumi.dexter.listener.PermissionRequest; //导入依赖的package包/类
private void configureDexterListeners() {
permissionListener = new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport report) {
Timber.d("Accepted: %s", report.getGrantedPermissionResponses());
Timber.d("Denied: %s", report.getDeniedPermissionResponses());
if (report.areAllPermissionsGranted()) {
Timber.d("All granted, requesting");
requestPicture();
}
}
@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> permissions, PermissionToken token) {
Timber.d("should show rationale");
token.continuePermissionRequest();
}
};
anyPermissionDeniedListener = DialogOnAnyDeniedMultiplePermissionsListener.Builder
.withContext(this)
.withTitle("Camera & file permissions")
.withMessage("Camera & file permissions are needed for saving pictures")
.withButtonText("Ok")
.build();
Dexter.continuePendingRequestsIfPossible(anyPermissionDeniedListener);
}
示例11: launchCamera
import com.karumi.dexter.listener.PermissionRequest; //导入依赖的package包/类
public void launchCamera(final CameraCallback cameraCallback) {
Dexter.withActivity(mActivity)
.withPermissions(
Manifest.permission.CAMERA,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.RECORD_AUDIO)
.withListener(new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport report) {
launchIntent();
}
@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> permissions, PermissionToken token) {
}
}).check();
SandriosBus.getBus()
.toObserverable()
.subscribe(new Consumer<Object>() {
@Override
public void accept(Object o) throws Exception {
if (o instanceof CameraOutputModel) {
CameraOutputModel outputModel = (CameraOutputModel) o;
if (cameraCallback != null) {
cameraCallback.onComplete(outputModel);
mInstance = null;
}
SandriosBus.complete();
}
}
});
}
示例12: onPermissionRationaleShouldBeShown
import com.karumi.dexter.listener.PermissionRequest; //导入依赖的package包/类
/**
* Decorates de permission listener execution with a given thread
*
* @param permissions The permissions that has been requested. Collections of values found in
* {@link android.Manifest.permission}
* @param token Token used to continue or cancel the permission request process. The permission
* request process will remain blocked until one of the token methods is called
*/
@Override public void onPermissionRationaleShouldBeShown(
final List<PermissionRequest> permissions, final PermissionToken token) {
thread.execute(new Runnable() {
@Override public void run() {
listener.onPermissionRationaleShouldBeShown(permissions, token);
}
});
}
示例13: getPermissionRequestShouldShowTokenMatcher
import com.karumi.dexter.listener.PermissionRequest; //导入依赖的package包/类
private static ArgumentMatcher<PermissionRequest> getPermissionRequestShouldShowTokenMatcher(
final String permission) {
return new ArgumentMatcher<PermissionRequest>() {
@Override public boolean matches(Object argument) {
PermissionRequest request = (PermissionRequest) argument;
return permission.equals(request.getName());
}
};
}
示例14: onPermissionRationaleShouldBeShown
import com.karumi.dexter.listener.PermissionRequest; //导入依赖的package包/类
@Override public void onPermissionRationaleShouldBeShown(final PermissionRequest permission,
final PermissionToken token) {
handler.post(new Runnable() {
@Override public void run() {
SampleBackgroundThreadPermissionListener.super.onPermissionRationaleShouldBeShown(
permission, token);
}
});
}
示例15: onPermissionRationaleShouldBeShown
import com.karumi.dexter.listener.PermissionRequest; //导入依赖的package包/类
@Override public void onPermissionRationaleShouldBeShown(PermissionRequest permissionRequest,
PermissionToken token) {
if (contextProvider.isActivityContextAvailable()){
Context context = contextProvider.getCurrentActivity();
PermissionsUIViews.showRationaleView(createRationaleResponseInstance(token), context,
getPermissionRationaleTitle(), getPermissionRationaleMessage());
}
}