Android main activity destroy(finish) automatically -


in app there 3 activities: a, b, , c. activity main activity.

when start activity b using intent, automatically destroyed. however, not finished when start b. then, when press button in device started using oncreate , i've lost data since not using intent go back.

the same happens when opening c b.

button.setonclicklistener(new onclicklistener() {              @override             public void onclick(view v) {                 // todo auto-generated method stub                 startactivity(new intent(activitya.this,                         activityb.class));             }         }); 

what's going on? how fix this?

if using 'activity b' sort of one-off result sounds need using startactivityforresult construct. see [the docs](http://developer.android.com/reference/android/app/activity.html#startactivityforresult(android.content.intent, int))

however, maintain state information 'activity a' without persisting anywhere want bundling information (fields user has filled in etc.) intent bundle passed 'activity b'. bundle delivered 'activity b's oncreate (and few other lifecycle points) can continue populating pertinent information 'activity b' , writing information intent bundle before restarting 'activity a' modd'ed bundle when done 'activity b'. here dragons. specific mechanism employed in our app strict (wrong?) control on back-stack. our 'activity a' has special manifest declaration of android:nohistory="true". means control happens when button pressed overriding onbackpressed() @ each activity , sending same bundle through new instance of activity came from. looks normal stack since wanting remember user input without persisting information anywhere it's usable solution.

this allows wizard input each stage of wizard input being it's own activity , validated , correct information being persisted @ end.

an alternative temporarily stored 'activity a's data in sharedpreferences area on restarting activity can pull out appropriate bits reassembling original state of 'actvity a' when left it. rest assured there little can when android wants kill activity can accommodate it's reasonable killing approaches outlined here.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -