Instant Apps Camera Intent

拈花ヽ惹草 提交于 2019-12-05 11:38:18

I fear the problem does not come from the permission but from the way you are launching your activity.

Instant Apps in fact cannot launch activities with explicit intents unless that specific intent has been made available to instant apps.

EDIT: Sorry I told you before that you are trying to launch an explicit intent. Actually new Intent(MediaStore.ACTION_IMAGE_CAPTURE) is an implicit one. Hence I do not understand why you have the security exception. Are you using latest canary 4 version ?

For the difference between an explicit intent and an implicit one:

  • Explicit intent target specifically another app or component

  • Implicit intent let the system choose which app should handle the intent. i.e. Intent intent = new Intent(ACTION_VIEW,Uri.parse("http://www.google.com");

I don't think capturing photos via the MediaStore.ACTION_IMAGE_CAPTURE intent will work at the moment unfortunately. Even if the activity could start, it requires write access to external storage to actually send back the full image and external storage is not available to Instant Apps (see restrictions). FileProvider is also not support on Instant Apps at the moment in case the capture intent could write to internal storage (I'm not sure about that).

The permission android.permission.CAMERA is supported though, you will just need to use the camera2 APIs. There is a code sample you can try out here.

With reference to Google issue tracker, The fix will be part of android 8.1 Oreo. Unfortunately it's not possible to fix through GMS, however we are sending out a patch for the fix to our partners, so they can adopt the fix even if they aren't building off of an 8.1 base.

If any issue persists, please report at Google issue tracker they will re-open to examine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!