This may happen because, in onCreate() on subActivity, are you putting
any finish() call.

> if (data.equals(null)) { alert("returned null"); }

You can't check like this. You can check in this way,

if(data == null);




Nithin


On Dec 23, 6:35 pm, ryan <[email protected]> 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 [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

Reply via email to