相机意图打开相机应用(仅第一次)

huangapple go评论85阅读模式
英文:

Camera intent open the camera app (only the first time)

问题

这里是上下文
在我的应用程序中,我需要拍摄照片,这就是为什么我使用相机意图。
这个功能运行得很完美,但只有在相机应用程序之前已经被打开过一次的情况下才有效。
确实,这个问题只在新设备或新模拟器上出现。

这里是问题
当我想要拍摄照片时,原生相机应用会打开,给我一些关于如何拍照的提示。这不是我应用程序内部的相机应用,而是独立的相机应用。我需要关闭这个相机应用,回到我的应用程序,然后再次尝试。
当我至少在设备的生命周期内访问一次相机应用时,就没有问题了。

这里是我在寻找的解决方案
我想要在我的应用程序中打开这个相机应用,即使是第一次。

我使用经典和官方的方式来拍摄照片。
> https://developer.android.com/training/camera/photobasics

编辑
我认为问题是因为第一次打开相机应用时,它会要求位置权限。所以我们需要在不要求这个权限的情况下打开意图,以保持焦点。

英文:

Here is the context:
In my app, I need to capture images, that's why I use camera intent.
This feature works perfectly, but only if the camera app was already been opened once before
Indeed, this issue appears only on a new device, or a new emulator

Here is the problem:
When I want to capture an image, the native camera app just open, giving to me some hints to how take pictures. That's not the camera app IN my app, but the camera app alone. I need to close this camera app, back to my app, and trying again
When I visit the camera app at least one time in the device's life, there is no issue

Here is what I'm looking for:
I want this camera app open in my app, even if it's the first time

I use the classic and official way to captures images
> https://developer.android.com/training/camera/photobasics

EDIT
I think the problem is because at the first time, the camera app asked for the location permission. So we need to open the intent without asking this permission, to keep the focus

答案1

得分: 1

> 当我想要拍摄一张照片时,原生相机应用会打开,并给我一些关于如何拍照的提示。

有大约26,000种Android设备型号。这些设备预装了几十甚至数百种不同的相机应用。任何一个这些应用在首次运行时的行为都会因应用而异。而且,这些应用在首次运行时的行为决定权在于这些应用的开发者,而不是你我。

> 那不是我应用中的相机应用,而是相机应用本身。

如果您正在使用ACTION_IMAGE_CAPTURE,正如您的问题所示,它从未是“在[您的]应用中”。它总是第三方应用,其中之一可能是预装的应用,也可能是用户安装的应用。而且,这些应用的行为由各自的开发者决定。

> 我希相机应用在我的应用中打开,即使是第一次。

抱歉,但这不在您的控制范围内。

英文:

> When I want to capture an image, the native camera app just open, giving to me some hints to how take pictures.

There are ~26,000 Android device models. These ship with dozens, if not hundreds, of different pre-installed camera apps. The behavior of any of those apps on first run of that app will vary by app. Moreover, the decision of how those apps behave when they are first run is up to the developers of those apps, not you or me.

> That's not the camera app IN my app, but the camera app alone

It is never "IN [your] app" if you are using ACTION_IMAGE_CAPTURE, as your question suggests that you are. It is always a third-party app, one of many pre-installed ones, or one of the user ones. And, again, the behavior of those apps are up to their respective developers.

> I want this camera app open in my app, even if it's the first time

Sorry, but that is not under your control.

huangapple
  • 本文由 发表于 2020年10月26日 23:17:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/64539919.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定