java - How to stop android system from redeliver old intent on Orientation Change? -
i start activity b intent extras , based on type of in oncreate process , works fine.
but when orientation alter same old intent re-delivered scheme me , whole process gets restarted since go through oncreate 1 time again.
my code take care of restoring previous state of activity when oncreate gets called if no old intent delivered it. since scheme re-delivers create activity think new intent , restarts whole process 1 time again.
i tried flag intent.getflags() != intent.flag_activity_launched_from_history
. flag prevents re-delivery in case of long press home button , activity launched history no effect on orientation change.
a dirty prepare proposed in thread dirty fix wondering if there proper way address problem.
thanks in advance
a 'clean' solution problem utilize fragments.
create own fragment subclass. in oncreate, sure phone call setretaininstance(true). in oncreate can start process. if doing work, homecoming null in oncreateview.
in activity's oncreate: - first seek find current instance of own fragment. - if not found, create brand new 1 , commit fragment transaction.
by calling setretaininstance(true) , first trying find before creating new fragment in activity's oncreate, maintain same fragment instance after rotation , fragment's oncreate won't called again.
java android android-intent android-activity android-orientation
No comments:
Post a Comment