本文整理汇总了Java中com.karumi.dexter.Dexter类的典型用法代码示例。如果您正苦于以下问题:Java Dexter类的具体用法?Java Dexter怎么用?Java Dexter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Dexter类属于com.karumi.dexter包,在下文中一共展示了Dexter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkCameraPermission
import com.karumi.dexter.Dexter; //导入依赖的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: initThings
import com.karumi.dexter.Dexter; //导入依赖的package包/类
private void initThings() {
loadingManager = new LoadingManager(this);
searchPresenter = new SearchPresenter(this);
notificationManager = new NotificationManager(this);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, 0 /* clientId */, this)
.addApi(Places.GEO_DATA_API)
.build();
autoCompleteTextView.setOnItemClickListener(this);
autoCompleteTextView.addTextChangedListener(this);
autoCompleteTextView.setOnEditorActionListener(this);
createPermissionListener();
Dexter.checkPermission(locationPermissionListener, Manifest.permission.ACCESS_COARSE_LOCATION);
}
示例3: checkPermissions
import com.karumi.dexter.Dexter; //导入依赖的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();
}
示例4: checkCameraPermission
import com.karumi.dexter.Dexter; //导入依赖的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();
}
示例5: askPermissions
import com.karumi.dexter.Dexter; //导入依赖的package包/类
protected void askPermissions(){
MultiplePermissionsListener dialogMultiplePermissionsListener =
DialogOnAnyDeniedMultiplePermissionsListener.Builder
.withContext(mContext)
.withTitle(getString(R.string.str_askpermission_title))
.withMessage(getString(R.string.str_askpermission_content))
.withButtonText(android.R.string.ok)
.build();
Dexter.withActivity(this)
.withPermissions(
Manifest.permission.READ_CONTACTS,
Manifest.permission.SEND_SMS,
Manifest.permission.READ_SMS
).withListener(dialogMultiplePermissionsListener
).check();
}
示例6: onCreate
import com.karumi.dexter.Dexter; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
Realm.init(this);
globalContext = this.getApplicationContext();
TwitterAuthConfig authConfig = new TwitterAuthConfig(getString(R.string.twitter_key),getString(R.string.twitter_secret));
Fabric.with(this, new Twitter(authConfig));
facebookInit();
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
Stetho.initialize(
Stetho.newInitializerBuilder(this)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(RealmInspectorModulesProvider.builder(this).build())
.build());
Dexter.initialize(this);
}
示例7: onCreate
import com.karumi.dexter.Dexter; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
sInstance = this;
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
OneSignal.startInit(this).setNotificationOpenedHandler(new MADBikeNotificationOpenedHandler(this)).init();
Branch.getAutoInstance(this);
Dexter.initialize(this);
}
示例8: onViewCreated
import com.karumi.dexter.Dexter; //导入依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
AnalyticsManager.getInstance().trackContentView("Map");
mParties = getResources().getStringArray(R.array.states_values);
setHasOptionsMenu(true);
createPermissionListeners();
initManagers();
initMap(savedInstanceState);
if (Dexter.isRequestOngoing()) {
return;
}
Dexter.checkPermission(locationPermissionListener, Manifest.permission.ACCESS_COARSE_LOCATION);
idStation = getArguments().getString(HomeActivity.STATION_ID);
}
示例9: onFabButtonClicked
import com.karumi.dexter.Dexter; //导入依赖的package包/类
@OnClick(R.id.fab)
public void onFabButtonClicked() {
AnalyticsManager.getInstance().trackSendIncidence();
if (Dexter.isRequestOngoing()) {
return;
}
Dexter.checkPermissions(cameraPermissionListener, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.CAMERA);
}
示例10: onCreateView
import com.karumi.dexter.Dexter; //导入依赖的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;
}
示例11: requestStoragePermissions
import com.karumi.dexter.Dexter; //导入依赖的package包/类
public static void requestStoragePermissions(Context context) {
PermissionListener dialogPermissionListener =
DialogOnDeniedPermissionListener.Builder
.withContext(context)
.withTitle("Write to Storage Permission")
.withMessage("Storage permission is required to save any manga to your phone.")
.withButtonText(android.R.string.ok)
.withIcon(R.mipmap.ic_launcher)
.build();
Dexter.withActivity((AppCompatActivity) context).withPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE).withListener(dialogPermissionListener).check();
}
示例12: request
import com.karumi.dexter.Dexter; //导入依赖的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();
}
示例13: takePictureViaIntent
import com.karumi.dexter.Dexter; //导入依赖的package包/类
private void takePictureViaIntent() {
if (Dexter.isRequestOngoing()) {
return;
}
CompositeMultiplePermissionsListener listener = new CompositeMultiplePermissionsListener(permissionListener, anyPermissionDeniedListener);
Dexter.checkPermissions(listener, Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
示例14: configureDexterListeners
import com.karumi.dexter.Dexter; //导入依赖的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);
}
示例15: launchCamera
import com.karumi.dexter.Dexter; //导入依赖的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();
}
}
});
}