Android startCamera gives me null Intent and … does it destroy my global variable?

邮差的信 提交于 2019-11-26 12:32:38

It's possible that launching of ACTION_IMAGE_CAPTURE will push your activity out of memory. You should check (I'd simply a log, debugger may have its own side effects) that onCreate() of your activity is called before onActivityResult(). If this is the case, you should prepare your activity to reinitialize itself, probably using onSaveInstanceState(Bundle).

Note that the decision whether to shut down the activity, or keep it in background, depends on the overall system state that is beyond your control. It won't surprise me if the decision when you take the first picture, is "shut him down!", but when you take picture again, it is "keep him in background".

It doesnot destroy the variables. But after So many days of research LOL I have got a solution of my mistake. When I put the debugger the method calls it like after taking a picture.

  • onCreate()
  • onActivityResult()
  • onCeate()
  • onResume()

Its fixed by just put these following lines in t the menifest. It happens due to camera config changes & window soft input mode.

             <activity
                android:name="packageName.Activity"
                android:configChanges="orientation|keyboardHidden|screenSize"
                android:label="@string/app_name"
                android:screenOrientation="portrait"
                android:windowSoftInputMode="adjustResize" >
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!