本文整理汇总了Java中pub.devrel.easypermissions.AfterPermissionGranted类的典型用法代码示例。如果您正苦于以下问题:Java AfterPermissionGranted类的具体用法?Java AfterPermissionGranted怎么用?Java AfterPermissionGranted使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AfterPermissionGranted类属于pub.devrel.easypermissions包,在下文中一共展示了AfterPermissionGranted类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: downloadFile
import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(WRITE_EXTERNAL_REQUEST_CODE)
public void downloadFile(String url, String userAgent, String contentDisposition, String mimetype) {
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setMimeType(mimetype);
cookieManager = CookieManager.getInstance();
PersistentConfig persistentConfig = new PersistentConfig(activity.getApplicationContext());
persistentConfig.setCookie(getCookies(Session.getSession(activity.getApplicationContext())));
cookieManager.setCookie(host, persistentConfig.getCookieString());
request.addRequestHeader("Cookie", getCookies(Session.getSession(activity.getApplicationContext())));
request.setDescription("Downloading file...");
request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimetype));
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
DownloadManager dManager = (DownloadManager) getActivity().getSystemService(DOWNLOAD_SERVICE);
dManager.enqueue(request);
}
示例2: createLayers
import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(PERMISSIONS_REQUEST_READ_STORAGE)
private void createLayers() {
if (EasyPermissions.hasPermissions(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE)) {
TileCache tileCache = AndroidUtil.createTileCache(getContext(),
"mapFragment",
this.mapView.getModel().displayModel.getTileSize(),
1.0f,
this.mapView.getModel().frameBufferModel.getOverdrawFactor());
final Layers layers = this.mapView.getLayerManager().getLayers();
final MapViewPosition mapViewPosition = this.mapView.getModel().mapViewPosition;
initializePosition(mapViewPosition);
TileRendererLayer tileRendererLayer = createTileRendererLayer(tileCache, mapViewPosition,
getMapFile(), getRenderTheme());
layers.add(tileRendererLayer);
LabelLayer labelLayer = new LabelLayer(AndroidGraphicFactory.INSTANCE, tileRendererLayer.getLabelStore());
mapView.getLayerManager().getLayers().add(labelLayer);
// overlay with a marker to show the goal position
this.goalLocationOverlay = new Marker(null, null, 0, 0);
layers.add(this.goalLocationOverlay);
createLocationLayer();
} else {
EasyPermissions.requestPermissions(
this,
"",
PERMISSIONS_REQUEST_READ_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE);
}
}
示例3: requireSomePermission
import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(num)
private void requireSomePermission() {
String[] perms = {
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.WRITE_SETTINGS
};
if (EasyPermissions.hasPermissions(this, perms)) {
// Already have permission, do the thing
Log.i("requireSomePermission", "Permissions Granted!");
} else {
// Do not have permissions, request them now
EasyPermissions.requestPermissions(this, "",
num, perms);
}
}
示例4: requireAllPermissionForInit
import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的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);
}
}
示例5: chooseAccount
import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的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);
}
}
示例6: chooseAccount
import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的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);
}
}
示例7: requestPerm
import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的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: chooseAccount
import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的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);
}
}
示例9: chooseAccount
import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的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)
void chooseAccount() {
if (EasyPermissions.hasPermissions(this, Manifest.permission.GET_ACCOUNTS)) {
String accountName = mSettingsManager.getString(SettingsConstants.PREF_ACCOUNT_NAME);
if (accountName != null && !accountName.isEmpty()) {
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,
getString(R.string.msg_needs_google_account),
REQUEST_PERMISSION_GET_ACCOUNTS,
Manifest.permission.GET_ACCOUNTS);
}
}
示例10: chooseAccount
import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的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)
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);
}
}
示例11: onResume
import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(LOCATION_MICROPHONE_PERM)
@Override
public void onResume() {
super.onResume();
String[] perms = {Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.RECORD_AUDIO};
if (EasyPermissions.hasPermissions(getContext(), perms)) {
mPresenter.startRecord(getContext());
mapView.onResume();
} else {
// Do not have permissions, request them now
EasyPermissions.requestPermissions(this, "",
LOCATION_MICROPHONE_PERM, perms);
}
}
示例12: getPerm
import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(RC_EXTERNAL_STORAGE_PHONE_STATE_PER)
private void getPerm() {
if (!EasyPermissions.hasPermissions(this, Constants.EXTERNAL_STORAGE_PHONE_STATE_PER)) {
// Ask for one permission
EasyPermissions.requestPermissions(this,
getString(R.string.rationale_camera),
RC_EXTERNAL_STORAGE_PHONE_STATE_PER,
Constants.EXTERNAL_STORAGE_PHONE_STATE_PER);
}
AdManager.getInstance(this)
.init(Constants.APPID, Constants.APPSECRET, false, true);
mBtnStartService = (Button) findViewById(R.id.maina_start_service);
mBtnUpdate = (Button) findViewById(R.id.maina_update);
mBtnShare = (Button) findViewById(R.id.maina_share);
mBtnStartService.setOnClickListener(this);
mBtnUpdate.setOnClickListener(this);
mBtnShare.setOnClickListener(this);
}
示例13: onAudioClick
import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(RECORD_AUDIO)
private void onAudioClick() {
// Check that we have permission to read images from external storage.
grantStoragePermission();
if (!EasyPermissions.hasPermissions(mActivity, Manifest.permission.RECORD_AUDIO)) {
EasyPermissions.requestPermissions(mActivity, "If you want to do this continue, " +
"you should give App record audio permission ", RECORD_AUDIO, Manifest.permission.RECORD_AUDIO);
}
// Choose file storage location, must be listed in res/xml/file_paths.xml
File dir = new File(Environment.getExternalStorageDirectory() + "/MoonlightNote/.audio");
if (!dir.exists()) {
boolean isDirCreate = dir.mkdirs();
if (BuildConfig.DEBUG) { Log.d(TAG, "onAudioClick: " + isDirCreate); }
}
displaySpeechRecognizer();
}
示例14: requestPermission
import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(STORAGE_PERMS)
private void requestPermission(int type) {
if (!EasyPermissions.hasPermissions(getActivity(),
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
EasyPermissions.requestPermissions(getActivity(),
"If you want to do this continue, " +
"you should give App storage permission ",
STORAGE_PERMS, Manifest.permission.WRITE_EXTERNAL_STORAGE);
} else {
if (type == 0) {
mFDatabaseUtils.exportNote(0);
} else {
mFDatabaseUtils.restoreAll();
}
}
}
示例15: findFriends
import pub.devrel.easypermissions.AfterPermissionGranted; //导入依赖的package包/类
@AfterPermissionGranted(CONTACTS_PERMISSION_REQUEST_CODE)
private void findFriends() {
if (ContactsController.Manager.isNeedUpdate(this)) {
if (EasyPermissions.hasPermissions(this, CONTACTS_PERMS)) {
ContactsController contactsController = new ContactsController(this);
contactsController.setPhone(AgUser.getPhone(this));
contactsController.silentFindFriends();
ContactsController.Manager.increment(this);
} else {
EasyPermissions.requestPermissions(this,
getString(R.string.permission_contacts),
CONTACTS_PERMISSION_REQUEST_CODE,
CONTACTS_PERMS);
}
}
}