當前位置: 首頁>>代碼示例>>Java>>正文


Java RxPermissions.isGranted方法代碼示例

本文整理匯總了Java中com.tbruyelle.rxpermissions.RxPermissions.isGranted方法的典型用法代碼示例。如果您正苦於以下問題:Java RxPermissions.isGranted方法的具體用法?Java RxPermissions.isGranted怎麽用?Java RxPermissions.isGranted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.tbruyelle.rxpermissions.RxPermissions的用法示例。


在下文中一共展示了RxPermissions.isGranted方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: callPhone

import com.tbruyelle.rxpermissions.RxPermissions; //導入方法依賴的package包/類
/**
     * 請求打電話權限
     */
    public static void callPhone(final RequestPermission requestPermission, RxPermissions rxPermissions, final BaseView view, RxErrorHandler errorHandler) {
//先確保是否已經申請過權限
        boolean isPermissionsGranted =
                rxPermissions
                        .isGranted(Manifest.permission.CALL_PHONE);

        if (isPermissionsGranted) {//已經申請過,直接執行操作
            requestPermission.onRequestPermissionSuccess();
        } else {//沒有申請過,則申請
            rxPermissions
                    .request(Manifest.permission.CALL_PHONE)
                    .compose(PermissionUtil.<Boolean>bindToLifecycle(view))//使用RXlifecycle,使subscription和activity一起銷毀
                    .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");
                            }
                        }
                    });
        }
    }
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:29,代碼來源:PermissionUtil.java

示例2: externalStorage

import com.tbruyelle.rxpermissions.RxPermissions; //導入方法依賴的package包/類
/**
 * 請求外部存儲的權限
 */
public static void externalStorage(final RequestPermission requestPermission, RxPermissions rxPermissions, final BaseView 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");
                        }
                    }
                });
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:28,代碼來源:PermissionUtil.java

示例3: sendSms

import com.tbruyelle.rxpermissions.RxPermissions; //導入方法依賴的package包/類
/**
     * 請求發送短信權限
     */
    public static void sendSms(final RequestPermission requestPermission, RxPermissions rxPermissions, final BaseView 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");
                            }
                        }
                    });
        }
    }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:28,代碼來源:PermissionUtil.java

示例4: callPhone

import com.tbruyelle.rxpermissions.RxPermissions; //導入方法依賴的package包/類
/**
     * 請求打電話權限
     */
    public static void callPhone(final RequestPermission requestPermission, RxPermissions rxPermissions, final BaseView 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");
                            }
                        }
                    });
        }
    }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:28,代碼來源:PermissionUtil.java

示例5: readPhonestate

import com.tbruyelle.rxpermissions.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");
                            }
                        }
                    });
        }
    }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:28,代碼來源:PermissionUtil.java

示例6: externalStorage

import com.tbruyelle.rxpermissions.RxPermissions; //導入方法依賴的package包/類
/**
 * 請求外部存儲的權限
 */
public static void externalStorage(final RequestPermission requestPermission, RxPermissions rxPermissions, final BaseView view, RxErrorHandler errorHandler) {
    //先確保是否已經申請過攝像頭,和寫入外部存儲的權限
    boolean isPermissionsGranted =
            rxPermissions
                    .isGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE);

    if (isPermissionsGranted) {//已經申請過,直接執行操作
        requestPermission.onRequestPermissionSuccess();
    } else {//沒有申請過,則申請
        rxPermissions
                .request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
                .compose(PermissionUtil.<Boolean>bindToLifecycle(view))//使用RXlifecycle,使subscription和activity一起銷毀
                .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");
                        }
                    }
                });
    }
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:29,代碼來源:PermissionUtil.java

示例7: sendSms

import com.tbruyelle.rxpermissions.RxPermissions; //導入方法依賴的package包/類
/**
     * 請求發送短信權限
     */
    public static void sendSms(final RequestPermission requestPermission, RxPermissions rxPermissions, final BaseView view, RxErrorHandler errorHandler) {
//先確保是否已經申請過權限
        boolean isPermissionsGranted =
                rxPermissions
                        .isGranted(Manifest.permission.SEND_SMS);

        if (isPermissionsGranted) {//已經申請過,直接執行操作
            requestPermission.onRequestPermissionSuccess();
        } else {//沒有申請過,則申請
            rxPermissions
                    .request(Manifest.permission.SEND_SMS)
                    .compose(PermissionUtil.<Boolean>bindToLifecycle(view))//使用RXlifecycle,使subscription和activity一起銷毀
                    .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");
                            }
                        }
                    });
        }
    }
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:29,代碼來源:PermissionUtil.java

示例8: externalStorage

import com.tbruyelle.rxpermissions.RxPermissions; //導入方法依賴的package包/類
/**
 * 請求外部存儲的權限
 */
public static void externalStorage(final RequestPermission requestPermission, RxPermissions rxPermissions, final BaseView 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");
                        }
                    }
                });
    }
}
 
開發者ID:Wan7451,項目名稱:mvparms,代碼行數:27,代碼來源:PermissionUtil.java

示例9: launchCamera

import com.tbruyelle.rxpermissions.RxPermissions; //導入方法依賴的package包/類
/**
 * 請求攝像頭權限
 */
public static void launchCamera(final RequestPermission requestPermission, RxPermissions rxPermissions, final BaseView 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");
                        }
                    }
                });
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:31,代碼來源:PermissionUtil.java

示例10: launchCamera

import com.tbruyelle.rxpermissions.RxPermissions; //導入方法依賴的package包/類
/**
 * 請求攝像頭權限
 */
public static void launchCamera(final RequestPermission requestPermission, RxPermissions rxPermissions, final BaseView 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)
                .compose(PermissionUtil.<Boolean>bindToLifecycle(view))//使用RXlifecycle,使subscription和activity一起銷毀
                .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");
                        }
                    }
                });
    }
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:32,代碼來源:PermissionUtil.java


注:本文中的com.tbruyelle.rxpermissions.RxPermissions.isGranted方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。