检查有无相机的权限
作者:互联网
检查有无相机的权限
public void actionCheckPermission(View view) { String perms = Manifest.permission.CAMERA; Integer nRet = 0; nRet = ContextCompat.checkSelfPermission(this, perms); if (nRet == PERMISSION_GRANTED) { Toast.makeText(this, "有权限", Toast.LENGTH_LONG).show(); } else if(nRet == PERMISSION_DENIED) { Toast.makeText(this, "没有权限", Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, "非法返回值", Toast.LENGTH_LONG).show(); } }
手机权限设置:
设置->授权管理->应用权限管理->权限管理
标签:Toast,show,LONG,相机,LENGTH,nRet,有无,权限 来源: https://www.cnblogs.com/CipherLab/p/12049063.html