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