本文整理汇总了Java中pub.devrel.easypermissions.EasyPermissions.hasPermissions方法的典型用法代码示例。如果您正苦于以下问题:Java EasyPermissions.hasPermissions方法的具体用法?Java EasyPermissions.hasPermissions怎么用?Java EasyPermissions.hasPermissions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pub.devrel.easypermissions.EasyPermissions
的用法示例。
在下文中一共展示了EasyPermissions.hasPermissions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例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);
}
}
示例4: 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);
}
}
示例5: saveToFileByPermission
import pub.devrel.easypermissions.EasyPermissions; //导入方法依赖的package包/类
@SuppressWarnings("unused")
@AfterPermissionGranted(PERMISSION_ID)
@OnClick(R.id.iv_save)
public void saveToFileByPermission() {
String[] permissions = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE};
if (EasyPermissions.hasPermissions(this, permissions)) {
saveToFile();
} else {
EasyPermissions.requestPermissions(this, "请授予保存图片权限", PERMISSION_ID, permissions);
}
}
示例6: 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);
}
}
示例7: 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)) {
mShareView.share();
} else {
EasyPermissions.requestPermissions(this, "请授予文件读写权限", PERMISSION_ID, permissions);
}
}
示例8: onCreate
import pub.devrel.easypermissions.EasyPermissions; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//check storage permissions
if(!EasyPermissions.hasPermissions(this,perms)){
EasyPermissions.requestPermissions(this,"App needs access to phone storage to work.",RC_PERMISSION,perms);
}else {
performTask();
}
}
示例9: 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);
}
}
示例10: requestExternalStorage
import pub.devrel.easypermissions.EasyPermissions; //导入方法依赖的package包/类
@AfterPermissionGranted(RC_EXTERNAL_STORAGE)
public void requestExternalStorage() {
if (EasyPermissions.hasPermissions(this, Manifest.permission.READ_EXTERNAL_STORAGE)) {
DownloadService.startService(this, mVersion.getDownloadUrl());
} else {
EasyPermissions.requestPermissions(this, "", RC_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE);
}
}
示例11: showImagePicker
import pub.devrel.easypermissions.EasyPermissions; //导入方法依赖的package包/类
@AfterPermissionGranted(RC_CAMERA_PERMISSIONS)
private void showImagePicker() {
// Check for camera permissions
if (!EasyPermissions.hasPermissions(this, cameraPerms)) {
EasyPermissions.requestPermissions(this,
"This sample will upload a picture from your Camera",
RC_CAMERA_PERMISSIONS, cameraPerms);
return;
}
// Choose file storage location
File file = new File(getExternalCacheDir(), UUID.randomUUID().toString());
mFileUri = Uri.fromFile(file);
// Camera
final List<Intent> cameraIntents = new ArrayList<Intent>();
final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
final PackageManager packageManager = getPackageManager();
final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);
for (ResolveInfo res : listCam){
final String packageName = res.activityInfo.packageName;
final Intent intent = new Intent(captureIntent);
intent.setComponent(new ComponentName(packageName, res.activityInfo.name));
intent.setPackage(packageName);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mFileUri);
cameraIntents.add(intent);
}
// Image Picker
Intent pickerIntent = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
Intent chooserIntent = Intent.createChooser(pickerIntent,
getString(R.string.picture_chooser_title));
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new
Parcelable[cameraIntents.size()]));
startActivityForResult(chooserIntent, TC_PICK_IMAGE);
}
示例12: 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);
}
}
示例13: 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);
}
}
示例14: haveNetworkPermission
import pub.devrel.easypermissions.EasyPermissions; //导入方法依赖的package包/类
/**
* 查询是否有网络权限
* @param context
* @return
*/
private static boolean haveNetworkPermission(Context context) {
String[] perms = new String[]{
Manifest.permission.INTERNET,
Manifest.permission.ACCESS_NETWORK_STATE,
Manifest.permission.ACCESS_WIFI_STATE,
};
return EasyPermissions.hasPermissions(context, perms);
}
示例15: haveReadPermission
import pub.devrel.easypermissions.EasyPermissions; //导入方法依赖的package包/类
/**
* 查询是否有读取权限
* @param context
* @return
*/
private static boolean haveReadPermission(Context context) {
String[] perms = new String[]{
Manifest.permission.READ_EXTERNAL_STORAGE
};
return EasyPermissions.hasPermissions(context, perms);
}