android - back button in listView causes crash -
i have edittext , button. push button, launches listview activity. click on item in listview, closes activity , sets edittext item clicked on.
but if listview , hit button clicking item, crashes. think need in onpause not sure if that's best way go it.
listview, when item clicked...
intent intent = new intent(); bundle b = new bundle(); b.putstring("text", ((textview) view).gettext().tostring()); intent.putextras(b); setresult(success_return_code, intent); finish();
onactivityresult....
bundle b = data.getextras(); meditcategory.settext(b.getstring("text"));
you getting exception: data
null
because activity did not return result.
by default, key end activity without setting result. check resultcode
parameter onactivityresult
see whether sub-activity returned because list item clicked:
@override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if (resultcode == success_return_code) { // todo handle data here list item click } }
the resultcode
result_canceled
if activity explicitly returned that, didn't return result, or crashed during operation (see docs activity).
Comments
Post a Comment