本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}