本文整理匯總了Java中com.tbruyelle.rxpermissions2.RxPermissions.isGranted方法的典型用法代碼示例。如果您正苦於以下問題:Java RxPermissions.isGranted方法的具體用法?Java RxPermissions.isGranted怎麽用?Java RxPermissions.isGranted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.tbruyelle.rxpermissions2.RxPermissions
的用法示例。
在下文中一共展示了RxPermissions.isGranted方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: launchCamera
import com.tbruyelle.rxpermissions2.RxPermissions; //導入方法依賴的package包/類
public static void launchCamera(final RequestPermission requestPermission, final PickerContract.IPickerView view) {
RxPermissions rxPermissions = new RxPermissions((Activity) view);
boolean isPermissionsGranted =
rxPermissions
.isGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE) &&
rxPermissions
.isGranted(Manifest.permission.CAMERA);
if (isPermissionsGranted) {
requestPermission.onRequestPermissionSuccess();
} else {
rxPermissions
.request(Manifest.permission.WRITE_EXTERNAL_STORAGE
, Manifest.permission.CAMERA)
.subscribe(new Consumer<Boolean>() {
@Override
public void accept(@NonNull Boolean aBoolean) throws Exception {
if (aBoolean) {
requestPermission.onRequestPermissionSuccess();
} else {
view.showMessage(((Activity) view).getResources().getString(R.string.request_permission_fail));
}
}
});
}
}
示例2: launchRecorder
import com.tbruyelle.rxpermissions2.RxPermissions; //導入方法依賴的package包/類
public static void launchRecorder(final RequestPermission requestPermission, final PickerContract.IPickerView view) {
RxPermissions rxPermissions = new RxPermissions((Activity) view);
boolean isPermissionsGranted =
rxPermissions
.isGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE) &&
rxPermissions
.isGranted(Manifest.permission.RECORD_AUDIO);
if (isPermissionsGranted) {
requestPermission.onRequestPermissionSuccess();
} else {
rxPermissions
.request(Manifest.permission.WRITE_EXTERNAL_STORAGE
, Manifest.permission.RECORD_AUDIO)
.subscribe(new Consumer<Boolean>() {
@Override
public void accept(@NonNull Boolean aBoolean) throws Exception {
if (aBoolean) {
requestPermission.onRequestPermissionSuccess();
} else {
view.showMessage(((Activity) view).getResources().getString(R.string.request_permission_fail));
}
}
});
}
}
示例3: externalStorage
import com.tbruyelle.rxpermissions2.RxPermissions; //導入方法依賴的package包/類
public static void externalStorage(final RequestPermission requestPermission, final PickerContract.IPickerView view) {
RxPermissions rxPermissions = new RxPermissions((Activity) view);
boolean isPermissionsGranted =
rxPermissions
.isGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (isPermissionsGranted) {
requestPermission.onRequestPermissionSuccess();
} else {
rxPermissions
.request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
.subscribe(new Consumer<Boolean>() {
@Override
public void accept(@NonNull Boolean aBoolean) throws Exception {
if (aBoolean) {
requestPermission.onRequestPermissionSuccess();
} else {
view.showMessage(((Activity) view).getResources().getString(R.string.request_permission_fail));
}
}
});
}
}
示例4: externalStorage
import com.tbruyelle.rxpermissions2.RxPermissions; //導入方法依賴的package包/類
/**
* 請求外部存儲的權限
*/
public static void externalStorage(final RequestPermission requestPermission, RxPermissions rxPermissions, final IView view, RxErrorHandler errorHandler) {
//先確保是否已經申請過攝像頭,和寫入外部存儲的權限
boolean isPermissionsGranted =
rxPermissions
.isGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (isPermissionsGranted) {//已經申請過,直接執行操作
requestPermission.onRequestPermissionSuccess();
} else {//沒有申請過,則申請
rxPermissions
.request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
.subscribe(new ErrorHandleSubscriber<Boolean>(errorHandler) {
@Override
public void onNext(Boolean granted) {
if (granted) {
Timber.tag(TAG).d("request WRITE_EXTERNAL_STORAGE and CAMERA success");
requestPermission.onRequestPermissionSuccess();
} else {
view.showMessage("request permissons failure");
}
}
});
}
}
示例5: sendSms
import com.tbruyelle.rxpermissions2.RxPermissions; //導入方法依賴的package包/類
/**
* 請求發送短信權限
*/
public static void sendSms(final RequestPermission requestPermission, RxPermissions rxPermissions, final IView view, RxErrorHandler errorHandler) {
//先確保是否已經申請過權限
boolean isPermissionsGranted =
rxPermissions
.isGranted(Manifest.permission.SEND_SMS);
if (isPermissionsGranted) {//已經申請過,直接執行操作
requestPermission.onRequestPermissionSuccess();
} else {//沒有申請過,則申請
rxPermissions
.request(Manifest.permission.SEND_SMS)
.subscribe(new ErrorHandleSubscriber<Boolean>(errorHandler) {
@Override
public void onNext(Boolean granted) {
if (granted) {
Timber.tag(TAG).d("request SEND_SMS success");
requestPermission.onRequestPermissionSuccess();
} else {
view.showMessage("request permissons failure");
}
}
});
}
}
示例6: callPhone
import com.tbruyelle.rxpermissions2.RxPermissions; //導入方法依賴的package包/類
/**
* 請求打電話權限
*/
public static void callPhone(final RequestPermission requestPermission, RxPermissions rxPermissions, final IView view, RxErrorHandler errorHandler) {
//先確保是否已經申請過權限
boolean isPermissionsGranted =
rxPermissions
.isGranted(Manifest.permission.CALL_PHONE);
if (isPermissionsGranted) {//已經申請過,直接執行操作
requestPermission.onRequestPermissionSuccess();
} else {//沒有申請過,則申請
rxPermissions
.request(Manifest.permission.CALL_PHONE)
.subscribe(new ErrorHandleSubscriber<Boolean>(errorHandler) {
@Override
public void onNext(Boolean granted) {
if (granted) {
Timber.tag(TAG).d("request SEND_SMS success");
requestPermission.onRequestPermissionSuccess();
} else {
view.showMessage("request permissons failure");
}
}
});
}
}
示例7: readPhonestate
import com.tbruyelle.rxpermissions2.RxPermissions; //導入方法依賴的package包/類
/**
* 請求獲取手機狀態的權限
*/
public static void readPhonestate(final RequestPermission requestPermission, RxPermissions rxPermissions, RxErrorHandler errorHandler) {
//先確保是否已經申請過權限
boolean isPermissionsGranted =
rxPermissions
.isGranted(Manifest.permission.READ_PHONE_STATE);
if (isPermissionsGranted) {//已經申請過,直接執行操作
requestPermission.onRequestPermissionSuccess();
} else {//沒有申請過,則申請
rxPermissions
.request(Manifest.permission.READ_PHONE_STATE)
.subscribe(new ErrorHandleSubscriber<Boolean>(errorHandler) {
@Override
public void onNext(Boolean granted) {
if (granted) {
Timber.tag(TAG).d("request SEND_SMS success");
requestPermission.onRequestPermissionSuccess();
} else {
Timber.tag(TAG).e("request permissons failure");
}
}
});
}
}
示例8: launchCamera
import com.tbruyelle.rxpermissions2.RxPermissions; //導入方法依賴的package包/類
/**
* 請求攝像頭權限
*/
public static void launchCamera(final RequestPermission requestPermission, RxPermissions rxPermissions, final IView view, RxErrorHandler errorHandler) {
//先確保是否已經申請過攝像頭,和寫入外部存儲的權限
boolean isPermissionsGranted =
rxPermissions
.isGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE) &&
rxPermissions
.isGranted(Manifest.permission.CAMERA);
if (isPermissionsGranted) {//已經申請過,直接執行操作
requestPermission.onRequestPermissionSuccess();
} else {//沒有申請過,則申請
rxPermissions
.request(Manifest.permission.WRITE_EXTERNAL_STORAGE
, Manifest.permission.CAMERA)
.subscribe(new ErrorHandleSubscriber<Boolean>(errorHandler) {
@Override
public void onNext(Boolean granted) {
if (granted) {
Timber.tag(TAG).d("request WRITE_EXTERNAL_STORAGE and CAMERA success");
requestPermission.onRequestPermissionSuccess();
} else {
view.showMessage("request permissons failure");
}
}
});
}
}