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


Java Dexter类代码示例

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

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

}
 
开发者ID:Mun0n,项目名称:MADBike,代码行数:18,代码来源:SearchActivity.java

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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