Android Exclude Some Camera Intent
I'm developing an app that will need to use a camera using the file input from WebView. So this is the code that I write and it is working with the google camera. In my webchromecl
Solution 1:
Edit this part:
for(ResolveInfo res : listCam) {
finalStringpackageName= res.activityInfo.packageName;
finalIntenti=newIntent(captureIntent);
i.setComponent(newComponentName(res.activityInfo.packageName, res.activityInfo.name));
i.setPackage(packageName);
i.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
cameraIntents.add(i);
}
To This one:
for(ResolveInfo res : listCam) {
finalStringpackageName= res.activityInfo.packageName;
finalIntenti=newIntent(captureIntent);
if(packageName.equals("ihate.this.package")||packageName.equals("begone.unwanted.package")){
Log.i("camera", res.activityInfo.packageName+" blocked!");
}else{
i.setComponent(newComponentName(res.activityInfo.packageName, res.activityInfo.name));
captureIntent.setPackage(packageName);
i.setPackage(packageName);
i.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
cameraIntents.add(i);
}
}
If you want to know the package name just Log the res.activityInfo.packageName
You can do the same approach for android 5.0
Solution 2:
You can restrict available apps by setPackage.
Solution 3:
No, what you are trying to do is not supported. You can either use setPackage to restrict it to one particular app, or leave the package null, and allow any capable app to handle the intent.
Post a Comment for "Android Exclude Some Camera Intent"