当前位置: 首页>>代码示例>>Java>>正文


Java PermissionRequest类代码示例

本文整理汇总了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();
}
 
开发者ID:akexorcist,项目名称:CameraSample,代码行数:21,代码来源:MainActivity.java

示例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();
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:20,代码来源:BootActivity.java

示例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();

    }
 
开发者ID:pooi,项目名称:Nearby,代码行数:25,代码来源:NurseRecordActivity.java

示例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);
  }
}
 
开发者ID:longtaoge,项目名称:Dexter,代码行数:22,代码来源:DexterInstance.java

示例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();

}
 
开发者ID:Gigigo-Android-Devs,项目名称:gigigo-utils-suite,代码行数:18,代码来源:AbstractPermissionListenerTest.java

示例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();

}
 
开发者ID:Gigigo-Android-Devs,项目名称:gigigo-utils-suite,代码行数:18,代码来源:AbstractPermissionListenerTest.java

示例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);
        }
    });
}
 
开发者ID:Mun0n,项目名称:MADBike,代码行数:12,代码来源:MADBikeBackgroundPermissionListener.java

示例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;
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:29,代码来源:SOSFragment.java

示例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();
}
 
开发者ID:daeng-id,项目名称:nfkita-mobile,代码行数:10,代码来源:RuntimePermissions.java

示例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);
}
 
开发者ID:fzymek,项目名称:FunWithAndroid,代码行数:28,代码来源:MainActivity.java

示例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();
                    }
                }
            });
}
 
开发者ID:sandrios,项目名称:sandriosCamera,代码行数:35,代码来源:SandriosCamera.java

示例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);
    }
  });
}
 
开发者ID:longtaoge,项目名称:Dexter,代码行数:17,代码来源:MultiplePermissionListenerThreadDecorator.java

示例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());
    }
  };
}
 
开发者ID:longtaoge,项目名称:Dexter,代码行数:10,代码来源:DexterInstanceTest.java

示例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);
    }
  });
}
 
开发者ID:longtaoge,项目名称:Dexter,代码行数:10,代码来源:SampleBackgroundThreadPermissionListener.java

示例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());
  }
}
 
开发者ID:Gigigo-Android-Devs,项目名称:gigigo-utils-suite,代码行数:10,代码来源:AbstractPermissionListener.java


注:本文中的com.karumi.dexter.listener.PermissionRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。