当前位置: 首页>>代码示例>>Java>>正文


Java EasyPermissions类代码示例

本文整理汇总了Java中pub.devrel.easypermissions.EasyPermissions的典型用法代码示例。如果您正苦于以下问题:Java EasyPermissions类的具体用法?Java EasyPermissions怎么用?Java EasyPermissions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EasyPermissions类属于pub.devrel.easypermissions包,在下文中一共展示了EasyPermissions类的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: requestWriteExternalStoragePermission

import pub.devrel.easypermissions.EasyPermissions; //导入依赖的package包/类
/**
 * Request runtime permissions method
 */
private void requestWriteExternalStoragePermission() {
    String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
    if (EasyPermissions.hasPermissions(this, permissions)) {
        //Up next .... request Location
        requestLocationPermission();
    } else {
        // Do not have permissions, request permissions
        EasyPermissions.requestPermissions(MainActivity.this,
                getString(R.string.write_storage_request),
                R.string.allow_permission,
                R.string.deny_permission,
                WRITE_EXTERNAL_STORAGE_PERMISSION,
                permissions);
    }
}
 
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:19,代码来源:MainActivity.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);
            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

示例5: 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

示例6: onRequestPermissionsResult

import pub.devrel.easypermissions.EasyPermissions; //导入依赖的package包/类
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {

    switch (requestCode){
        case 1:
            if (grantResults.length>0 && grantResults[0]==PackageManager.PERMISSION_GRANTED){
                openAlbum();
            }else {
                Toast.makeText(UIUtils.getContext(),"你关闭了权限功能",Toast.LENGTH_SHORT).show();
            }
            break;

        default:
            break;
    }

    super.onRequestPermissionsResult(requestCode, permissions, grantResults);

    // Forward results to EasyPermissions
    EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
}
 
开发者ID:android-jian,项目名称:topnews,代码行数:22,代码来源:SettingFragment.java

示例7: requestPerm

import pub.devrel.easypermissions.EasyPermissions; //导入依赖的package包/类
/**
 * 申请权限的方法
 */

@AfterPermissionGranted(RC)
private void requestPerm() {
    String[] perms = new String[]{
            Manifest.permission.INTERNET,
            Manifest.permission.ACCESS_NETWORK_STATE,
            Manifest.permission.ACCESS_WIFI_STATE,
            Manifest.permission.RECORD_AUDIO,
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE
    };


    if (EasyPermissions.hasPermissions(getContext(), perms)) {
        App.showToast(R.string.label_permission_ok);
        // 判断页面的跳转
        getActivity().finish();
        LaunchActivity.showWitchAcitivty(getActivity());
    } else {
        EasyPermissions.requestPermissions(this,
                getString(R.string.title_assist_permissions),
                RC,
                perms);
    }
}
 
开发者ID:FZZFVII,项目名称:pipe,代码行数:29,代码来源:PermisionsFragment.java

示例8: requestForStoragePermission

import pub.devrel.easypermissions.EasyPermissions; //导入依赖的package包/类
public void requestForStoragePermission() {
  final String[] permissions = new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE };
  if (EasyPermissions.hasPermissions(getActivity(), permissions)) {
    appDetailsPresenter.onPermissionGranted();
  } else {
    EasyPermissions.requestPermissions(this, getString(R.string.storage_permission_requirement),
        STORAGE_PERMISSION, permissions);
  }
}
 
开发者ID:Arjun-sna,项目名称:android-permission-checker-app,代码行数:10,代码来源:AppDetailsFragment.java

示例9: getPermissions

import pub.devrel.easypermissions.EasyPermissions; //导入依赖的package包/类
@TargetApi(23)
private void getPermissions() {
  String[] permissions = new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE,
      Manifest.permission.RECORD_AUDIO};
  if (!EasyPermissions.hasPermissions(MainActivity.this, permissions)) {
    EasyPermissions.requestPermissions(this, getString(R.string.permissions_required),
        PERMISSION_REQ, permissions);
  }
}
 
开发者ID:Arjun-sna,项目名称:Android-AudioRecorder-App,代码行数:10,代码来源:MainActivity.java

示例10: onPermissionsDenied

import pub.devrel.easypermissions.EasyPermissions; //导入依赖的package包/类
@Override
public void onPermissionsDenied(int requestCode, List<String> permissions) {
	if (EasyPermissions.somePermissionPermanentlyDenied(this, permissions)) {
		new AppSettingsDialog.Builder(this)
				.setRationale(R.string.rationale)
				.setTitle(R.string.title_rationale)
				.setPositiveButton(R.string.app_settings)
				.setNegativeButton(R.string.cancel)
				.setRequestCode(SETTINGS_REQUEST_CODE)
				.build()
				.show();
	}
}
 
开发者ID:EduardoVernier,项目名称:bikedeboa-android,代码行数:14,代码来源:MapActivity.java

示例11: onRequestPermissionsResult

import pub.devrel.easypermissions.EasyPermissions; //导入依赖的package包/类
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);

    // Forward results to EasyPermissions
    EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
}
 
开发者ID:xm0625,项目名称:VBrowser-Android,代码行数:8,代码来源:MainActivity.java

示例12: onRequestPermissionsResult

import pub.devrel.easypermissions.EasyPermissions; //导入依赖的package包/类
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);

    // Forward results to EasyPermissions
    EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
}
 
开发者ID:CodingCodersCode,项目名称:EvolvingNetLib,代码行数:8,代码来源:DownloadListTestActivity.java

示例13: onPermissionsDenied

import pub.devrel.easypermissions.EasyPermissions; //导入依赖的package包/类
@Override
public void onPermissionsDenied(int requestCode, List<String> perms) {
    //Log.d(TAG, "onPermissionsDenied:" + requestCode + ":" + perms.size());

    // (Optional) Check whether the user denied any permissions and checked "NEVER ASK AGAIN."
    // This will display a dialog directing them to enable the permission in app settings.
    if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
        new AppSettingsDialog.Builder(this).build().show();
    }
}
 
开发者ID:CodingCodersCode,项目名称:EvolvingNetLib,代码行数:11,代码来源:DownloadListTestActivity.java

示例14: requestPermissions

import pub.devrel.easypermissions.EasyPermissions; //导入依赖的package包/类
@Override
public void requestPermissions() {
    EasyPermissions.requestPermissions(this,
            getString(R.string.external_storage_permission_required),
            REQUEST_STORAGE_PERMISSION,
            Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
 
开发者ID:googlecodelabs,项目名称:android-storage-permissions,代码行数:8,代码来源:ImagesFragment.java

示例15: 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


注:本文中的pub.devrel.easypermissions.EasyPermissions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。