Search in sources :

Example 16 with RxPermissions

use of com.tbruyelle.rxpermissions3.RxPermissions in project Now by XunMengWinter.

the class BigImagePagerActivity method saveImage.

private void saveImage(Drawable drawable, String imageUrl) {
    RxPermissions rxPermissions = new RxPermissions(this);
    rxPermissions.request(Manifest.permission.WRITE_EXTERNAL_STORAGE).subscribe(isGranted -> {
        if (isGranted) {
            boolean isSaved = ImageUtil.saveImage(this, drawable, imageUrl);
            if (isSaved) {
                App.showToast(getString(R.string.save_image_success, Environment.DIRECTORY_PICTURES));
            } else {
                App.showToast(R.string.save_image_failed);
            }
        } else {
            new AlertDialog.Builder(BigImagePagerActivity.this).setMessage(R.string.save_image_failed_permission).setPositiveButton(R.string.ok, null).create().show();
        }
    });
}
Also used : RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions)

Example 17 with RxPermissions

use of com.tbruyelle.rxpermissions3.RxPermissions in project MVPFrames by RockyQu.

the class WelcomeActivity method create.

@Override
public void create(Bundle savedInstanceState) {
    rxPermissions = new RxPermissions(this);
    PermissionUtils.requestPermissions(new PermissionUtils.RequestPermission() {

        @Override
        public void onRequestPermissionSuccess() {
            startNextActivity();
        }

        @Override
        public void onRequestPermissionFailure() {
            // 如果失败跳到到应用设置页面
            AppUtils.applicationDetailsSettings(WelcomeActivity.this);
            finish();
        }
    }, rxPermissions, Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
Also used : RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) PermissionUtils(com.tool.common.utils.PermissionUtils)

Example 18 with RxPermissions

use of com.tbruyelle.rxpermissions3.RxPermissions in project SmartMesh_Android by SmartMeshFoundation.

the class MainFragmentUI method installPackage.

/**
 * install app method
 */
@SuppressLint("CheckResult")
private void installPackage(Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        String apkName = intent.getStringExtra("apkName");
        installFile = new File(Environment.getExternalStorageDirectory() + "/download/" + apkName);
        RxPermissions rxPermissions = new RxPermissions(MainFragmentUI.this);
        rxPermissions.request(Manifest.permission.REQUEST_INSTALL_PACKAGES).subscribe(new Consumer<Boolean>() {

            @Override
            public void accept(Boolean aBoolean) throws Exception {
                if (aBoolean) {
                    Utils.installApk8(MainFragmentUI.this, installFile);
                } else {
                    MyToast.showToast(NextApplication.mContext, getString(R.string.open_permission_install_package));
                    Uri packageURI = Uri.parse("package:" + getPackageName());
                    Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, packageURI);
                    startActivityForResult(intent, 200);
                }
            }
        });
    }
}
Also used : RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) Intent(android.content.Intent) File(java.io.File) Uri(android.net.Uri) SuppressLint(android.annotation.SuppressLint)

Example 19 with RxPermissions

use of com.tbruyelle.rxpermissions3.RxPermissions in project SmartMesh_Android by SmartMeshFoundation.

the class SplashActivity method onAnimationEnd.

@SuppressLint("CheckResult")
@Override
public void onAnimationEnd(Animation animation) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        final RxPermissions rxPermissions = new RxPermissions(this);
        rxPermissions.request(Manifest.permission.CAMERA, Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_CONTACTS).subscribe(new Consumer<Boolean>() {

            @Override
            public void accept(Boolean aBoolean) {
                if (aBoolean) {
                    intoNextMethod();
                } else {
                    openPermission();
                }
            }
        });
    } else {
        intoNextMethod();
    }
}
Also used : RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) SuppressLint(android.annotation.SuppressLint)

Example 20 with RxPermissions

use of com.tbruyelle.rxpermissions3.RxPermissions in project SmartMesh_Android by SmartMeshFoundation.

the class Utils method getIMEI.

/**
 * Access to mobile phone IMEI number
 */
public static String getIMEI(Context mContext) {
    final TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
        try {
            RxPermissions rxPermissions = new RxPermissions((Activity) mContext);
            rxPermissions.request(Manifest.permission.READ_PHONE_STATE);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return telephonyManager.getDeviceId();
}
Also used : RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) TelephonyManager(android.telephony.TelephonyManager) IOException(java.io.IOException)

Aggregations

RxPermissions (com.tbruyelle.rxpermissions2.RxPermissions)31 Intent (android.content.Intent)8 SuppressLint (android.annotation.SuppressLint)6 Permission (com.tbruyelle.rxpermissions2.Permission)4 View (android.view.View)3 GifSizeFilter (com.connxun.ltcx.utils.GifSizeFilter)3 RxPermissions (com.tbruyelle.rxpermissions3.RxPermissions)3 Manifest (android.Manifest)2 Uri (android.net.Uri)2 Button (android.widget.Button)2 OnClick (butterknife.OnClick)2 GlideEngine (com.zhihu.matisse.engine.impl.GlideEngine)2 CaptureStrategy (com.zhihu.matisse.internal.entity.CaptureStrategy)2 Consumer (io.reactivex.functions.Consumer)2 IOException (java.io.IOException)2 Activity (android.app.Activity)1 Context (android.content.Context)1 ActivityInfo (android.content.pm.ActivityInfo)1 Cursor (android.database.Cursor)1 Bundle (android.os.Bundle)1