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