【问题标题】:Why doesn't Android ask for the desired camera app from within my own app?为什么 Android 不从我自己的应用程序中请求所需的相机应用程序?
【发布时间】:2011-05-26 06:48:31
【问题描述】:

我有一个按钮,可以通向手机上安装的任何相机应用程序,这很好用。但是,在某些手机上,相机应用程序不会返回任何结果,并且一个应用程序会返回损坏的图像。我在这些手机上安装了另一个更好的相机应用程序,但是在安装旧的相机应用程序时我无法运行它。

如果有多个候选人,Android 不应该自动询问我想使用哪个应用程序吗?我是否需要在我的应用中执行其他操作才能做到这一点?

编辑:这甚至在他们的生活中从未有过“选择默认相机应用程序”对话框的手机上。即使我使用 Intent.createChooser(intent, "Choose camera app");选择器永远不会出现。

这是我使用的代码:

Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
startActivityForResult(intent, RESULT_TAKEPHOTO);

【问题讨论】:

    标签: android camera


    【解决方案1】:

    你必须使用 Intent 类的createChooser() 方法。 你的代码看起来像这样。

    Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
    startActivityForResult(Intent.createChooser(intent, "Choose cam application"), RESULT_TAKEPHOTO);
    

    【讨论】:

    • 我看过这个,但这只会在正常出现时才会出现,唯一的区别是你不能选择默认的运行而不是显示选择器(在这种情况下,最好只选择第一次)。就我而言,即使是这个强制版本也不会显示选择器。好像没有其他相机应用程序的意图标签设置正确,因此它不会响应选择器。这没有意义,所以我一直假设这是我的应用程序的错。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-22
    • 2012-02-07
    • 1970-01-01
    相关资源
    最近更新 更多