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();
}
});
}
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);
}
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);
}
}
});
}
}
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();
}
}
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();
}
Aggregations