本文整理了Java中android.app.Activity.checkPermission()
方法的一些代码示例,展示了Activity.checkPermission()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.checkPermission()
方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:checkPermission
暂无
代码示例来源:origin: com.uphyca/android-junit4-robolectric
/**
* @param permission
* @param pid
* @param uid
* @return
* @see android.content.ContextWrapper#checkPermission(java.lang.String,
* int, int)
*/
public int checkPermission(String permission,
int pid,
int uid) {
return mActivity.checkPermission(permission, pid, uid);
}
代码示例来源:origin: fookwood/Launcher3
protected Bitmap getThumbnailOfLastPhoto() {
boolean canReadExternalStorage = getActivity().checkPermission(
Manifest.permission.READ_EXTERNAL_STORAGE, Process.myPid(), Process.myUid()) ==
PackageManager.PERMISSION_GRANTED;
if (!canReadExternalStorage) {
// MediaStore.Images.Media.EXTERNAL_CONTENT_URI requires
// the READ_EXTERNAL_STORAGE permission
return null;
}
Cursor cursor = MediaStore.Images.Media.query(getContext().getContentResolver(),
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[] { MediaStore.Images.ImageColumns._ID,
MediaStore.Images.ImageColumns.DATE_TAKEN},
null, null, MediaStore.Images.ImageColumns.DATE_TAKEN + " DESC LIMIT 1");
Bitmap thumb = null;
if (cursor != null) {
if (cursor.moveToNext()) {
int id = cursor.getInt(0);
thumb = MediaStore.Images.Thumbnails.getThumbnail(getContext().getContentResolver(),
id, MediaStore.Images.Thumbnails.MINI_KIND, null);
}
cursor.close();
}
return thumb;
}
代码示例来源:origin: derry/delion
/**
* If the device has NFC, construct a BeamCallback and pass it to Android.
*
* @param activity Activity that is sending out beam messages.
* @param provider Provider that returns the URL that should be shared.
*/
public static void registerForBeam(final Activity activity, final BeamProvider provider) {
final NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(activity);
if (nfcAdapter == null) return;
if (activity.checkPermission(Manifest.permission.NFC, Process.myPid(), Process.myUid())
== PackageManager.PERMISSION_DENIED) return;
try {
final BeamCallback beamCallback = new BeamCallback(activity, provider);
nfcAdapter.setNdefPushMessageCallback(beamCallback, activity);
nfcAdapter.setOnNdefPushCompleteCallback(beamCallback, activity);
} catch (IllegalStateException e) {
Log.w("BeamController", "NFC registration failure. Can't retry, giving up.");
}
}
}
内容来源于网络,如有侵权,请联系作者删除!