如何限制从应用中使用第三方相机应用的 [英] How to restrict use of third party camera app from your app

查看:404
本文介绍了如何限制从应用中使用第三方相机应用的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有动力凸轮的应用程序是安装在我的设备的第三方相机应用。我从我的应用程序打开摄像头,当我点击打开拍照键,它给我的相机像设备摄像头的选择与动力凸轮一起。我想上单击打开拍照键,摄像设备应该拿开,换句话说,我想利用权力从凸轮我的应用程序限制用户

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

推荐答案

如果您要运行只有官方的摄像头,你可以使用下面的意图(基于的官方教程):

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);
    }
}

不幸的是,许多设备都使用自定义preinstalled摄像头的应用程序,而 com.android.camera 可能无法使用。

如果你想筛选出特定的软件包,你不喜欢,你必须prepare你自己的选择对话框(见例的这里)。如果你知道选择哪个包,你可以跳过对话。例如。是可能的过滤列表,从而只包括系统的包。但即便如此,也不能保证会有只有一个注册到完成的 MediaStore.ACTION_IM​​AGE_CAPTURE 意图系统包。

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.

这篇关于如何限制从应用中使用第三方相机应用的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆