当前位置: 首页>>代码示例>>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;未经允许,请勿转载。