如何获得相机应用程序的包名 [英] How to get package name of camera application

查看:642
本文介绍了如何获得相机应用程序的包名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢previous答复,

Thanks for previous replies,

是否有可能得到它安装在设备上的摄像头应用程序包的名称?如果操作系统自定义默认包名称是由设备制造商改变。我怎样才能通过编码得到的包叫什么名字?我不知道这将是可能的。

Is it possible to get Package name of camera application which is installed on the device? If the OS is customized the default package name is changed by the device manufacturer. How can I get the package name through coding ? I am not sure this will be possible.

推荐答案

我不知道,但我觉得您可以使用指定的意图获取应用程序包名 ..

I am not sure, but I think you can get package name of application using specified intent..

看这个code获取该处理的特定意图,可用的应用程序的信息,

Look at this code for getting available application information which handle the specific intent,

/**
 * Indicates whether the specified action can be used as an intent. This
 * method queries the package manager for installed packages that can
 * respond to an intent with the specified action. If no suitable package is
 * found, this method returns false.
 *
 * @param context The application's environment.
 * @param action The Intent action to check for availability.
 *
 * @return True if an Intent with the specified action can be sent and
 *         responded to, false otherwise.
 */
public static boolean isIntentAvailable(Context context, String action) {
    final PackageManager packageManager = context.getPackageManager();
    final Intent intent = new Intent(action);
    List list =
            packageManager.queryIntentActivities(intent,
                    PackageManager.MATCH_DEFAULT_ONLY);
    return list.size() > 0;
}

现在使用的相机意向就可以得到它处理 IMAGE_CAPTURE 意图,并利用这些信息,你可以很容易地得到包名的应用程序的信息。

Now using Camera intent you can get the application information which handles the IMAGE_CAPTURE intent and using that information you can easily get package name.

更新:

在你的情况的具体意图是

In your case the specific intent is

Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

编辑:

List<ResolveInfo> listCam = packageManager.queryIntentActivities(intent, 0);
for (ResolveInfo res : listCam) {
    Log.e("Camera Application Package Name and Activity Name",res.activityInfo.packageName + " " + res.activityInfo.name));
}

试试这个,让我知道发生什么事。

Try this and let me know what happen..

这篇关于如何获得相机应用程序的包名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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