I'm writing an app that has multiple activities. Activity A calls Activity B, not expecting a result. Then if a button is pressed B startsActivityForResult with Activity C. When Activity C is done, it makes an intent with all of the extras it needs and finishes. The problem is that when it calls this.finish() or just finish(), it brings me all the way back out to Activity A. onActivityResult in Activity B is not called. What is 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 the edits!
editor.commit();
startActivity(in);
Activity B: Starts Activity C for 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 the result of activity c...
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// If the request went well (OK) and the request was PICK_CONTACT_REQUEST
if (resultCode == Activity.RESULT_OK && requestCode==0) { //upload a 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 is the issue with that? It happens with an activity that doesn't return a result as well, so its not just this one.
Thanks!