java - Finishing an activity brings me back to my first activity -
i'm writing app has multiple activities. activity calls activity b, not expecting result. if button pressed b startsactivityforresult activity c. when activity c done, makes intent of extras needs , finishes. problem when calls this.finish() or finish(), brings me way out activity a. onactivityresult in activity b not called. wrong?
activity a: starts activity b
intent in = new intent(ccstart.this,mainmenu.class); in.putextra("uid",loginresponse); sharedpreferences settings = getsharedpreferences(prefs_name, 0); sharedpreferences.editor editor = settings.edit(); editor.putstring("usr",text_user.gettext().tostring()); // commit edits! editor.commit(); startactivity(in);
activity b: starts activity c result
intent intent = new intent(mainmenu.this,filebrowser.class); startactivityforresult(intent,0);
activity c: return statement
intent result = new intent(); result.putextra("fname", file.getabsolutepath()); this.setresult(activity.result_ok, result); finish();
activity b: upon result of activity c...
@override protected void onactivityresult(int requestcode, int resultcode, intent data) { // if request went (ok) , request pick_contact_request if (resultcode == activity.result_ok && requestcode==0) { //upload file final string fname = data.getextras().getstring("fname"); final sharedpreferences settings = getsharedpreferences(prefs_name, 0); //load settings final string uid = settings.getstring("uid", ""); new thread(new runnable() { public void run() { // todo auto-generated method stub dofileupload(fname, uid); } }).start(); } }
what issue that? happens activity doesn't return result well, not one.
thanks!
you need explicit close activity when start next one, if not, stays in "stack of activities" can access button or when next activity closes.
you need call finish on activity after started activity b
Comments
Post a Comment