当前位置: 首页>>代码示例>>Java>>正文


Java PermissionUtils类代码示例

本文整理汇总了Java中permissions.dispatcher.PermissionUtils的典型用法代码示例。如果您正苦于以下问题:Java PermissionUtils类的具体用法?Java PermissionUtils怎么用?Java PermissionUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PermissionUtils类属于permissions.dispatcher包,在下文中一共展示了PermissionUtils类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deniedPermission

import permissions.dispatcher.PermissionUtils; //导入依赖的package包/类
private void deniedPermission() {
  preStart();
  StringBuilder permission = new StringBuilder();
  if (!PermissionUtils.hasSelfPermissions(this, Manifest.permission.ACCESS_COARSE_LOCATION)) {
    permission.append("位置权限");
  }
  if (!PermissionUtils.hasSelfPermissions(this, Manifest.permission.CAMERA)) {
    if (permission.length() > 0) permission.append(", ");
    permission.append("拍照权限");
  }
  if (!PermissionUtils.hasSelfPermissions(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
    if (permission.length() > 0) permission.append(", ");
    permission.append("存储权限");
  }
  if (!PermissionUtils.hasSelfPermissions(this, Manifest.permission.READ_PHONE_STATE)) {
    if (permission.length() > 0) permission.append(", ");
    permission.append("电话权限");
  }
  Toost.message(String.format("很遗憾, 部分功能的使用依赖于%s权限", permission));
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:21,代码来源:WelcomeActivity.java

示例2: onRequestPermissionsResult

import permissions.dispatcher.PermissionUtils; //导入依赖的package包/类
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);

    if (requestCode == REQUEST_SHOWMAP) {
        if (PermissionUtils.getTargetSdkVersion(getActivity()) < 23 && !PermissionUtils.hasSelfPermissions(getActivity(), PERMISSION_SHOWMAP)) {
            // metodo para cuando no hay acceso al mapa.
            onMapDenied();
        }
        if (PermissionUtils.verifyPermissions(grantResults)) {
            // mostramos el mapa
            showMap();
        } else {
            if (PermissionUtils.shouldShowRequestPermissionRationale(getActivity(), PERMISSION_SHOWMAP)) {
                // mostramos el modal para no preguntar nunca mas.
                onMapNeverAskAgain();
            } else {
                // metodo para cuando no hay acceso al mapa.
                onMapDenied();
            }
        }
    }
}
 
开发者ID:TeamValente,项目名称:Mi-SUBE-Android,代码行数:24,代码来源:MapViewFragment.java

示例3: checkPermission

import permissions.dispatcher.PermissionUtils; //导入依赖的package包/类
/**
 * 检查权限
 *
 * @return
 */
public boolean checkPermission() {
    if (Build.VERSION.SDK_INT >= 23) {
        boolean hasPermission = PermissionUtils.hasSelfPermissions(this, permissionList);
        MainActivityPermissionsDispatcher.showCheckPermissionStateWithCheck(this);
        if (!LocationUtils.isGpsProviderEnabled(this)) {
            return false;
        }
        return hasPermission;
    }
    return true;
}
 
开发者ID:Twelvelines,项目名称:AndroidMuseumBleManager,代码行数:17,代码来源:MainActivity.java

示例4: checkPermission

import permissions.dispatcher.PermissionUtils; //导入依赖的package包/类
/**
 * 检查权限
 * @return
 */
public boolean checkPermission(){
    if (Build.VERSION.SDK_INT >= 23){
        boolean hasPermission = PermissionUtils.hasSelfPermissions(this, permissionList);
        MainActivityPermissionsDispatcher.showCheckPermissionStateWithCheck(this);
        if (!LocationUtils.isGpsProviderEnabled(this)){
            return false;
        }
        return hasPermission;
    }
    return true;
}
 
开发者ID:haodynasty,项目名称:AndroidBleManager,代码行数:16,代码来源:MainActivity.java

示例5: showMapWithCheck

import permissions.dispatcher.PermissionUtils; //导入依赖的package包/类
private void showMapWithCheck() {
    if (PermissionUtils.hasSelfPermissions(getActivity(), PERMISSION_SHOWMAP)) {
        showMap();
    } else {
        if (PermissionUtils.shouldShowRequestPermissionRationale(getActivity(), PERMISSION_SHOWMAP)) {
            showMapRationale(new ShowMapPermissionRequest(getActivity()));
        } else {
            ActivityCompat.requestPermissions(getActivity(), PERMISSION_SHOWMAP, REQUEST_SHOWMAP);
        }
    }
}
 
开发者ID:TeamValente,项目名称:Mi-SUBE-Android,代码行数:12,代码来源:MapViewFragment.java

示例6: onRequestPermissionsResult

import permissions.dispatcher.PermissionUtils; //导入依赖的package包/类
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
{
	super.onRequestPermissionsResult(requestCode, permissions, grantResults);
	// NOTE: delegate the permission handling to generated method
	ActivitySplashPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
	if (PermissionUtils.verifyPermissions(grantResults))
	{
		mHandler.sendEmptyMessage(INIT_RESULT);
	}
	else
	{
		initViewDenied();
	}
}
 
开发者ID:libit,项目名称:lr_dialer,代码行数:16,代码来源:ActivitySplash.java

示例7: onRequestPermissionsResult

import permissions.dispatcher.PermissionUtils; //导入依赖的package包/类
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    // 1つでも許可されないパーミッションがあった場合はActivityを終了させる
    if (!PermissionUtils.verifyPermissions(grantResults)) {
        finish();
    }
    PermissionRequireActivityPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
}
 
开发者ID:shts,项目名称:NogiFeed,代码行数:9,代码来源:PermissionRequireActivity.java


注:本文中的permissions.dispatcher.PermissionUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。