Could you post your exact configuration from your AndroidManifest for the activities that you are calling from and returning a result from?
The reason I ask is that I am struggling with a couple of activities in my app. One should be calling the other using StartActivityForResult but I am getting the dreaded 'Activity is launching as a new task, so cancelling activity result' problem. Neither of my activities are configured in any special way... no weird launchmode or anything but yet it still fails to work for me. Cheers. On Dec 23 2009, 4:23 pm, ryan <[email protected]> wrote: > Yeah I just found this out myself and came to post. Thanks for the > added input! > > On Dec 23, 6:35 am, Lance Nanek <[email protected]> wrote: > > > I've seen onActivityResult get called immediately once before as well. > > The activity getting started bystartActivityForResulthad 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 <[email protected]> wrote: > > > > Hello, > > > > Im trying to do a basicstartActivityForResult, 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

