I have power cam app which is a third party camera app installed in my device. I am opening camera from my app, when i click on open camera button, it gives me choice of cameras like device camera along with power cam. I want that on clicking the open camera button, device camera should get open, in other words i want to restrict the user from using power cam from my app
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If you want to run only the official camera, you can use the following intent (based on the official tutorial):
static final int REQUEST_IMAGE_CAPTURE = 1;
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
takePictureIntent.setPackage("com.android.camera");
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
Unfortunately, many devices come with custom preinstalled camera apps, and com.android.camera
may not be available.
If you want to filter out specific packages that you don't like, you must prepare your own chooser dialog (see example here). You can skip the dialog if you know which package to choose. E.g. it is possible to filter the list to only include "system" packages. But even then, there is no guarantee that there will be only one system package that is registered to fulfill the MediaStore.ACTION_IMAGE_CAPTURE intent.
标签:
android-camera