本文整理汇总了Java中com.karumi.dexter.MultiplePermissionsReport类的典型用法代码示例。如果您正苦于以下问题:Java MultiplePermissionsReport类的具体用法?Java MultiplePermissionsReport怎么用?Java MultiplePermissionsReport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MultiplePermissionsReport类属于com.karumi.dexter包,在下文中一共展示了MultiplePermissionsReport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkCameraPermission
import com.karumi.dexter.MultiplePermissionsReport; //导入依赖的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.MultiplePermissionsReport; //导入依赖的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.MultiplePermissionsReport; //导入依赖的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: onCreateView
import com.karumi.dexter.MultiplePermissionsReport; //导入依赖的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;
}
示例5: request
import com.karumi.dexter.MultiplePermissionsReport; //导入依赖的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();
}
示例6: configureDexterListeners
import com.karumi.dexter.MultiplePermissionsReport; //导入依赖的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);
}
示例7: launchCamera
import com.karumi.dexter.MultiplePermissionsReport; //导入依赖的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();
}
}
});
}
示例8: onPermissionsChecked
import com.karumi.dexter.MultiplePermissionsReport; //导入依赖的package包/类
@Override public void onPermissionsChecked(MultiplePermissionsReport report) {
super.onPermissionsChecked(report);
if (!report.areAllPermissionsGranted()) {
showDialog();
}
}
示例9: onPermissionsChecked
import com.karumi.dexter.MultiplePermissionsReport; //导入依赖的package包/类
@Override public void onPermissionsChecked(MultiplePermissionsReport report) {
super.onPermissionsChecked(report);
if (!report.areAllPermissionsGranted()) {
showSnackbar();
}
}
示例10: onPermissionsChecked
import com.karumi.dexter.MultiplePermissionsReport; //导入依赖的package包/类
@Override
public void onPermissionsChecked(MultiplePermissionsReport report) {
if (report.areAllPermissionsGranted() && report.getGrantedPermissionResponses().size() == 3) {
for (PermissionGrantedResponse permissionGrantedResponse : report.getGrantedPermissionResponses()) {
if (!validatePermissionCamera(permissionGrantedResponse)) {
return;
}
}
bottomSheetDialog.show();
}
}
示例11: onPermissionsChecked
import com.karumi.dexter.MultiplePermissionsReport; //导入依赖的package包/类
@Override
public void onPermissionsChecked(MultiplePermissionsReport report) {
if (report.areAllPermissionsGranted() && report.getGrantedPermissionResponses().size() == 2) {
for (PermissionGrantedResponse permissionGrantedResponse : report.getGrantedPermissionResponses()) {
if (!validatePermission(permissionGrantedResponse)) {
finish();
}
}
}
}
示例12: onPermissionsChecked
import com.karumi.dexter.MultiplePermissionsReport; //导入依赖的package包/类
@Override
public void onPermissionsChecked(MultiplePermissionsReport report) {
if (report.areAllPermissionsGranted() && report.getGrantedPermissionResponses().size() == 2) {
for (PermissionGrantedResponse permissionGrantedResponse : report.getGrantedPermissionResponses()) {
if (!validatePermission(permissionGrantedResponse)) {
return;
}
}
}
initWorkout();
}
示例13: initializeVoiceService
import com.karumi.dexter.MultiplePermissionsReport; //导入依赖的package包/类
/**
* Initialize voice service
* @param context
* @param registrationListener
* @param callback
* @throws Exception
*/
public static void initializeVoiceService(final Activity context, final RegistrationListener registrationListener, final Callback<VoiceService> callback) throws Exception {
if (callback == null) {
throw new Exception("callback cannot be null");
}
if (registrationListener == null) {
throw new Exception("registrationListener cannot be null");
}
// Permissions
Dexter.withActivity(context)
.withPermissions(PERMISSION_LIST)
.withListener(new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport report) {
if (!report.areAllPermissionsGranted()) {
callback.onFailure(new Exception("The following permissions are required: \n" + TextUtils.join("\n", PERMISSION_LIST)));
return;
}
try {
VoiceService service = VoiceService.newInstance(context.getApplicationContext(), registrationListener);
callback.onSuccess(service);
} catch (IOException e) {
callback.onFailure(e);
}
}
@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> permissions, PermissionToken token) {
}
})
.withErrorListener(new PermissionRequestErrorListener() {
@Override
public void onError(DexterError error) {
callback.onFailure(new Exception("The following permissions are required: \n" + TextUtils.join("\n", PERMISSION_LIST)));
}
})
.onSameThread()
.check();
}
示例14: onCreate
import com.karumi.dexter.MultiplePermissionsReport; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
_receiverController = new ReceiverController(this);
if (UserService.getInstance().IsAnUserSaved()) {
List<String> userList = new ArrayList<>();
userList.add(UserService.getInstance().GetUser().GetName());
_userView.setAdapter(new ArrayAdapter<>(LoginActivity.this, android.R.layout.simple_dropdown_item_1line, userList));
}
// Set up the login form.
_userView = findViewById(R.id.user);
_passwordView = findViewById(R.id.password);
_passwordView.setOnEditorActionListener((textView, id, keyEvent) -> {
if (id == R.id.login || id == EditorInfo.IME_NULL) {
attemptLogin();
return true;
}
return false;
});
com.rey.material.widget.Button userSignInButton = findViewById(R.id.user_sign_in_button);
userSignInButton.setOnClickListener(view -> attemptLogin());
_loginFormView = findViewById(R.id.login_form);
_progressView = findViewById(R.id.login_progress);
Dexter.withActivity(this)
.withPermissions(PERMISSIONS_TO_REQUEST)
.withListener(new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport report) {
if (report.areAllPermissionsGranted()) {
Toasty.success(LoginActivity.this, "All permissions granted! Thanks!", Toast.LENGTH_LONG).show();
}
}
@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> permissions, PermissionToken token) {
}
}).check();
}
示例15: successful
import com.karumi.dexter.MultiplePermissionsReport; //导入依赖的package包/类
@Override
public void successful(MultiplePermissionsReport report) {
refreshBluetooth();
}