本文整理匯總了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);
}