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


Java EasyPermissions.requestPermissions方法代碼示例

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


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

示例1: requireAllPermissionForInit

import pub.devrel.easypermissions.EasyPermissions; //導入方法依賴的package包/類
@AfterPermissionGranted(WRITE_EXTERNAL_STORAGE)
private void requireAllPermissionForInit() {
    //可以隻獲取寫或者讀權限,同一個權限Group下隻要有一個權限申請通過了就都可以用了
    String[] perms = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
    if (EasyPermissions.hasPermissions(this, perms)) {
        // Already have permission, do the thing
        if(!initReady){
            mainInit();
            initReady = true;
        }
        if(videoSniffer != null) {
            videoSniffer.startSniffer();
        }
        if (mainWebView != null) {
            mainWebView.resumeTimers();
            mainWebView.onShow();
        }
        startRefreshGoBackButtonStateThread();
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, "下載需要讀寫外部存儲權限",
                WRITE_EXTERNAL_STORAGE, perms);
    }
}
 
開發者ID:xm0625,項目名稱:VBrowser-Android,代碼行數:25,代碼來源:MainActivity.java

示例2: chooseAccount

import pub.devrel.easypermissions.EasyPermissions; //導入方法依賴的package包/類
/**
 * Attempts to set the account used with the API credentials. If an account
 * name was previously saved it will use that one; otherwise an account
 * picker dialog will be shown to the user. Note that the setting the
 * account to use with the credentials object requires the app to have the
 * GET_ACCOUNTS permission, which is requested here if it is not already
 * present. The AfterPermissionGranted annotation indicates that this
 * function will be rerun automatically whenever the GET_ACCOUNTS permission
 * is granted.
 */
@AfterPermissionGranted(REQUEST_PERMISSION_GET_ACCOUNTS)
private void chooseAccount() {
    if (EasyPermissions.hasPermissions(
            this, Manifest.permission.GET_ACCOUNTS)) {
        String accountName = getPreferences(Context.MODE_PRIVATE)
                .getString(PREF_ACCOUNT_NAME, null);
        if (accountName != null) {
            mCredential.setSelectedAccountName(accountName);
            getResultsFromApi();
        } else {
            // Start a dialog from which the user can choose an account
            startActivityForResult(
                    mCredential.newChooseAccountIntent(),
                    REQUEST_ACCOUNT_PICKER);
        }
    } else {
        // Request the GET_ACCOUNTS permission via a user dialog
        EasyPermissions.requestPermissions(
                this,
                "This app needs to access your Google account (via Contacts).",
                REQUEST_PERMISSION_GET_ACCOUNTS,
                Manifest.permission.GET_ACCOUNTS);
    }
}
 
開發者ID:webianks,項目名稱:Crimson,代碼行數:35,代碼來源:CheckupReminders.java

示例3: chooseAccount

import pub.devrel.easypermissions.EasyPermissions; //導入方法依賴的package包/類
/**
 * Attempts to set the account used with the API credentials. If an account
 * name was previously saved it will use that one; otherwise an account
 * picker dialog will be shown to the user. Note that the setting the
 * account to use with the credentials object requires the app to have the
 * GET_ACCOUNTS permission, which is requested here if it is not already
 * present. The AfterPermissionGranted annotation indicates that this
 * function will be rerun automatically whenever the GET_ACCOUNTS permission
 * is granted.
 */
@AfterPermissionGranted(REQUEST_PERMISSION_GET_ACCOUNTS)
private void chooseAccount() {
    if (EasyPermissions.hasPermissions(
            context, Manifest.permission.GET_ACCOUNTS)) {
        String accountName = context.getPreferences(Context.MODE_PRIVATE)
                .getString(PREF_ACCOUNT_NAME, null);
        if (accountName != null) {
            mCredential.setSelectedAccountName(accountName);
            getResultsFromApi();
        } else {
            // Start a dialog from which the user can choose an account
            context.startActivityForResult(
                    mCredential.newChooseAccountIntent(),
                    REQUEST_ACCOUNT_PICKER);
        }
    } else {
        // Request the GET_ACCOUNTS permission via a user dialog
        EasyPermissions.requestPermissions(
                context,
                "This app needs to access your Google account (via Contacts).",
                REQUEST_PERMISSION_GET_ACCOUNTS,
                Manifest.permission.GET_ACCOUNTS);
    }
}
 
開發者ID:Pl4gue,項目名稱:homeworkManager-android,代碼行數:35,代碼來源:GetHomeworkPresenter.java

示例4: chooseAccount

import pub.devrel.easypermissions.EasyPermissions; //導入方法依賴的package包/類
/**
 * Attempts to set the account used with the API credentials. If an account
 * name was previously saved it will use that one; otherwise an account
 * picker dialog will be shown to the user. Note that the setting the
 * account to use with the credentials object requires the app to have the
 * GET_ACCOUNTS permission, which is requested here if it is not already
 * present. The AfterPermissionGranted annotation indicates that this
 * function will be rerun automatically whenever the GET_ACCOUNTS permission
 * is granted.
 */
@AfterPermissionGranted(REQUEST_PERMISSION_GET_ACCOUNTS)
private void chooseAccount() {
    if (EasyPermissions.hasPermissions(
            context, Manifest.permission.GET_ACCOUNTS)) {
        String accountName = context.getPreferences(Context.MODE_PRIVATE)
                .getString(PREF_ACCOUNT_NAME, null);
        if (accountName != null) {
            mCredential.setSelectedAccountName(accountName);
            postHomeworkToApi(entryToAdd);
        } else {
            // Start a dialog from which the user can choose an account
            context.startActivityForResult(
                    mCredential.newChooseAccountIntent(),
                    REQUEST_ACCOUNT_PICKER);
        }
    } else {
        // Request the GET_ACCOUNTS permission via a user dialog
        EasyPermissions.requestPermissions(
                context,
                "This app needs to access your Google account (via Contacts).",
                REQUEST_PERMISSION_GET_ACCOUNTS,
                Manifest.permission.GET_ACCOUNTS);
    }
}
 
開發者ID:Pl4gue,項目名稱:homeworkManager-android,代碼行數:35,代碼來源:AddHomeworkPresenter.java

示例5: cameraTask

import pub.devrel.easypermissions.EasyPermissions; //導入方法依賴的package包/類
@AfterPermissionGranted(CAMERA_PERM)
private void cameraTask() {
    String[] perms = {Manifest.permission.CAMERA, Manifest.permission.VIBRATE};
    if (EasyPermissions.hasPermissions(this, perms)) {
        initCamera();
    } else {
        // Request one permission
        EasyPermissions.requestPermissions(this,
                getResources().getString(R.string.str_request_camera_message),
                CAMERA_PERM, perms);
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:13,代碼來源:CaptureActivity.java

示例6: requestCamera

import pub.devrel.easypermissions.EasyPermissions; //導入方法依賴的package包/類
@AfterPermissionGranted(RC_CAMERA_PERM)
@Override
public void requestCamera() {
    if (EasyPermissions.hasPermissions(this, Manifest.permission.CAMERA)) {
        if (mView != null) {
            mView.onOpenCameraSuccess();
        }
    } else {
        EasyPermissions.requestPermissions(this, "", RC_CAMERA_PERM, Manifest.permission.CAMERA);
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:12,代碼來源:SelectImageActivity.java

示例7: requestLocationPermission

import pub.devrel.easypermissions.EasyPermissions; //導入方法依賴的package包/類
/**
 * proxy request permission
 */
@AfterPermissionGranted(NearbyActivity.LOCATION_PERMISSION)
private void requestLocationPermission() {
    if (EasyPermissions.hasPermissions(this, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION,
            Manifest.permission.READ_PHONE_STATE)) {
        startLbs();
    } else {
        EasyPermissions.requestPermissions(this, getString(R.string.need_lbs_permission_hint), LOCATION_PERMISSION,
                Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.READ_PHONE_STATE);
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:14,代碼來源:MainActivity.java

示例8: saveToFileByPermission

import pub.devrel.easypermissions.EasyPermissions; //導入方法依賴的package包/類
@SuppressWarnings("unused")
@AfterPermissionGranted(PERMISSION_ID)
public void saveToFileByPermission() {
    String[] permissions = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE};
    if (EasyPermissions.hasPermissions(this, permissions)) {
        if (mType == TYPE_SHARE) {
            mFragment.share();
        } else {
            mFragment.save();
        }
    } else {
        EasyPermissions.requestPermissions(this, "請授予文件讀寫權限", PERMISSION_ID, permissions);
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:15,代碼來源:TweetShareActivity.java

示例9: requestLocationPermission

import pub.devrel.easypermissions.EasyPermissions; //導入方法依賴的package包/類
/**
 * proxy request permission
 */
@AfterPermissionGranted(LOCATION_PERMISSION)
private void requestLocationPermission() {

    if (isEnabledLocation()) {
        if (EasyPermissions.hasPermissions(this, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.READ_PHONE_STATE)) {
            startLbs();
        } else {
            EasyPermissions.requestPermissions(this, getString(R.string.need_lbs_permission_hint), LOCATION_PERMISSION,
                    Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.READ_PHONE_STATE);
        }
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:16,代碼來源:NearbyActivity.java

示例10: create

import pub.devrel.easypermissions.EasyPermissions; //導入方法依賴的package包/類
@Override
public void create(Bundle savedInstanceState) {
    // 權限處理
    if (EasyPermissions.hasPermissions(this, PermissionUtils.PERMISSIONS)) {
        this.startNextActivity();
    } else {
        // Ask for dangerous permission.
        EasyPermissions.requestPermissions(this, getString(R.string.PermissionsMessage),
                PermissionUtils.PERMISSION_CODE, PermissionUtils.PERMISSIONS);
    }
}
 
開發者ID:RockyQu,項目名稱:MVVMFrames,代碼行數:12,代碼來源:WelcomeActivity.java

示例11: onCreate

import pub.devrel.easypermissions.EasyPermissions; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    textView = findViewById(R.id.text);
    button = findViewById(R.id.button);
    imageView = findViewById(R.id.imageView);

    textView.setText(R.string.welcome_message);
    button.setText(R.string.button_text);
    imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);

    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                getAssets().open("synset_words.txt")
        ));
        while (true) {
            String line = reader.readLine();
            if (line == null) break;
            synsetWords.add(line);
        }

    } catch (IOException e) {
        e.printStackTrace();
    }

    if (EasyPermissions.hasPermissions(this, perms)) {
        initListener();

        ModelWrapper.readFile(getAssets(), "squeezenet.daq");
        ModelWrapper.setOutput("prob");
        ModelWrapper.compile(ModelWrapper.PREFERENCE_FAST_SINGLE_ANSWER);
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, "Please grant",
                321, perms);
    }
}
 
開發者ID:daquexian,項目名稱:DNNLibrary,代碼行數:40,代碼來源:MainActivity.java

示例12: requestExternalStorage

import pub.devrel.easypermissions.EasyPermissions; //導入方法依賴的package包/類
@AfterPermissionGranted(RC_EXTERNAL_STORAGE)
@Override
public void requestExternalStorage() {
    if (EasyPermissions.hasPermissions(this, Manifest.permission.READ_EXTERNAL_STORAGE)) {
        if (mView == null) {
            handleView();
        }
    } else {
        EasyPermissions.requestPermissions(this, "", RC_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE);
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:12,代碼來源:SelectImageActivity.java

示例13: doApplyPermissions

import pub.devrel.easypermissions.EasyPermissions; //導入方法依賴的package包/類
@AfterPermissionGranted(100)
private void doApplyPermissions() {
    if (EasyPermissions.hasPermissions(this, EasyPermissions.PERMS)) {
        LogInfo.log("zhuqiao", "doApplyPermissions success");
        init();
        return;
    }
    EasyPermissions.requestPermissions(this, getString(2131100595), 100, EasyPermissions.PERMS);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:10,代碼來源:SplashActivity.java

示例14: cameraTask

import pub.devrel.easypermissions.EasyPermissions; //導入方法依賴的package包/類
@AfterPermissionGranted(CAMERA_PERM)
private void cameraTask() {
    String[] perms = {Manifest.permission.CAMERA, Manifest.permission.VIBRATE};
    if (EasyPermissions.hasPermissions(this, perms)) {
        initCamera();
    } else {
        // Request one permission
        EasyPermissions.requestPermissions(this, "請求獲取相機權限", CAMERA_PERM, perms);
    }
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:11,代碼來源:CaptureActivity.java

示例15: getDownloadOperating

import pub.devrel.easypermissions.EasyPermissions; //導入方法依賴的package包/類
@AfterPermissionGranted(101)
private void getDownloadOperating() {
    if (hasStoragePermissions()) {
        downloadUrl();
    } else {
        EasyPermissions.requestPermissions(this, getString(R.string.rationale_storage), 101, STORAGE);
    }
}
 
開發者ID:alphater,項目名稱:garras,代碼行數:9,代碼來源:PhotoFragment.java


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