在Fragment中点击按钮启动相机拍照,在Fragment所依附的activity中重写onActivityResult方法,然后去接收,能进入到onActivityResult方法,但是返回的data是null。这个该如何解决?
已经指定了图片存放的路径,如果在onActivityResult中通过指定路径去取,改如何处理?
怪我咯2017-04-17 17:27:19
First of all, what kind of mobile phone does the questioner use?
I have also encountered the first case of returning null.
1 Whether permissions are set
2 Whether the application takes up too much memory, which leads to an error when opening the camera
The second situation is easy to handle. Just get it
But it may happen that the path you set is null
The occurrence of null is basically caused by insufficient memory. It’s best to check if there is a memory leak
大家讲道理2017-04-17 17:27:19
Have you added permissions?
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
黄舟2017-04-17 17:27:19
I have encountered this before. It seems that the requestcode returned by the fragment is negative. You can print it out and take a look.
怪我咯2017-04-17 17:27:19
Take a look here:
https://segmentfault.com/q/1010000005951643
That’s where I answered.
There is one in the SCDN blog below.