I need to check runtime-permissions for the background application whom I am sending some data through Intent.
I am broadcasting an Intent from appA to App-B in the background. Now, based on data in Intent app-B will start performing some task in the background itself. Hence, by the time I explicitly open appB, it will be ready having some data needed for further operation.
Now, I need to check run-time(Internet) permission for appB. is there any way to achieve the scenario?
if(hasPermission("com.appb.packge",new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}){
//your intent
}
boolean hasPermission(String pkgName,String permissions[]) {
PackageManager packageManager = getPackageManager();
boolean hasPermission = false;
for(String permission:permissions) {
if (packageManager.checkPermission(permission, pkgName) != PackageManager.PERMISSION_GRANTED) {
return false;
}
hasPermission = true;
}
return hasPermission;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.