Activity Killed/Oncreate Called After Taking Picture via Intent

Activity killed / onCreate called after taking picture via intent

Actually the camera causes the orientation change in your activity that is why your activity is being destroyed and recreated.

Add this in your manifest file it will prevent the orientation change and your activity will not get destroyed and recreated.

<activity
android:name=".YourActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait" >
</activity>

onCreate called before and after onActivityResult

Actually the camera causes the orientation change in your activity that is why your activity is being destroyed and recreated.

Add this in your manifest file it will prevent the orientation change and your activity will not get destroyed and recreated.

<activity
android:name=".YourActivity"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait" >
</activity>

Activity killed / onCreate called after taking picture via intent

Android - Activity seems to not get called after the intent returns

Every picture you add, gets converted to a byte[] array, and gets stored as an extra in the result intent.

That is a really bad idea.

though no errors can be found in the logs

You are probably getting "FAILED BINDER TRANSACTION" warnings.

Any reason why this might be happening ?

My guess is that you are attempting to pass too much data via IPC. The Intent that you supply to setResult() is passed from your app to a core OS process, then back to your app and the caller of startActivityForResult(). At best, you can pass 1MB in an IPC transaction, and depending on what else is going on at the time, the limit may be substantially lower.

Either:

  • Have one activity, not two, by using fragments for the individual bits of UI and using a shared ViewModel to expose the results of one fragment to another; or

  • Carefully hold onto these images in a shared cache, so you are passing cache keys as extras, not byte[]; or

  • Find some other architecture that you like that does not involve putting large byte[] values into an Intent for use with startActivity(), startActivityForResult(), or setResult()



Related Topics



Leave a reply



Submit