Yeah I just found this out myself and came to post. Thanks for the added input!
On Dec 23, 6:35 am, Lance Nanek <lna...@gmail.com> wrote: > I've seen onActivityResult get called immediately once before as well. > The activity getting started by startActivityForResult had launchMode > set to singleTask in the manifest. There was a message in the logs > from the ActivityManager saying: > "Activity is launching as a new task, so cancelling activity result." > > Changing the launch mode fixed it. > > On Dec 23, 8:35 am, ryan <ryan.yoos...@gmail.com> wrote: > > > Hello, > > > Im trying to do a basic startActivityForResult, but onActivityResult > > is being called before the subactivity has a chance to call setResult. > > > ---------------------------- > > main activity's menu handler for a specific button-press: > > startActivityForResult(new Intent(this, SubActivity.class), someInt); > > > main activity's onActivityResult(int reqestCode, int resultCode, > > Intent data) { > > alert(Integer.toString(resultCode)); // always 0 (RESULT_CANCELED?) > > alert(Integer.toString(requestCode)); // always someInt > > if (data == null) { alert("returned null"); } // SEE BELOW > > > SubActivity extends listactivity: > > onListItemClick(ListView l, View v, int i, long id) { > > result = new Intent(); > > result.putExtra("key","value); > > setResult(RESULT_OK, result); > > finish();} > > > ----------------------------- > > > the activity and subactivity execute fine, the result is where my > > problem comes in. > > > from "SEE BELOW" above: > > this line will always alert "returned null", however if i change this > > line to: > > if (data.equals(null)) { alert("returned null"); } > > i get a NullPointerException before the subactivity can visibly start. > > the subactivity's onCreate normally logs to the debugger, but nothing > > appears if I cause a NullPointerException, which leads me to believe > > that onActivityResult is being called before the subactivity is > > created. > > > i've taken a look at the notepad examples along other examples on the > > web and my code appears consistent with them. > > > plz halp -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en