android.support.v4.app.FragmentActivity.checkSelfPermission()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中android.support.v4.app.FragmentActivity.checkSelfPermission()方法的一些代码示例,展示了FragmentActivity.checkSelfPermission()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FragmentActivity.checkSelfPermission()方法的具体详情如下:
包路径:android.support.v4.app.FragmentActivity
类名称:FragmentActivity
方法名:checkSelfPermission

FragmentActivity.checkSelfPermission介绍

暂无

代码示例

代码示例来源:origin: googlecreativelab/shadercam

/**
 * Returns true if the Activity has access to a given permission.
 * Always returns true on platforms below M.
 */
public boolean hasSelfPermission(String permission) {
  // Below Android M all permissions are granted at install time and are already available.
  return getActivity().checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED;
}

代码示例来源:origin: googlecreativelab/shadercam

/**
 * Returns true if the Activity has access to all given permissions.
 */
public boolean hasSelfPermission(String[] permissions) {
  // Verify that all required permissions have been granted
  for (String permission : permissions) {
    if (getActivity().checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: JustinRoom/JSCKit

@TargetApi(Build.VERSION_CODES.M)
public boolean isGranted(@NonNull Fragment fragment, String permission) {
  final FragmentActivity fragmentActivity = fragment.getActivity();
  if (fragmentActivity == null) {
    throw new IllegalStateException("This fragment must be attached to an activity.");
  }
  return fragmentActivity.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED;
}

代码示例来源:origin: WangDaYeeeeee/Waves

/** <br> permission. */
private void requestPermission(int permissionCode) {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
    return;
  }
  switch (permissionCode) {
    case Waves.WRITE_EXTERNAL_STORAGE:
      if (getActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
          != PackageManager.PERMISSION_GRANTED) {
        this.requestPermissions(new String[] {android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
      } else {
        this.downloadShot();
      }
      break;
  }
}

代码示例来源:origin: varunon9/Remote-Control-PC

@TargetApi(Build.VERSION_CODES.M)
private void checkForPermissionAndDownload(String name, String path) {
  if (getActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
      != PackageManager.PERMISSION_GRANTED) {
    // Should we show an explanation?
    if (getActivity().shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
      Toast.makeText(getActivity(), "Write Permission is necessary to download", Toast.LENGTH_LONG).show();
    } else {
      getActivity().requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 2);
      //2 is integer constant for WRITE_EXTERNAL_STORAGE permission, uses in onRequestPermissionResult
    }
  } else {
    downloadFile(name, path);
  }
}

代码示例来源:origin: Somethingweirdhere/Secure-Photo-Viewer

if(type!=null) {
  if (Build.VERSION.SDK_INT >= 23) {
    if (getActivity().checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
      rootView=typeMethod(rootView,urinormal,container,type,inflater);
    } else {

相关文章

微信公众号

最新文章

更多

FragmentActivity类方法