dimanche 17 mai 2015

Activity not going back on single back press and i am sending data to previous too so i am not able to do that?

I had googled so many time for this problem. After that i am putting my question here.

I have two activity both have list in it. On click of first list item i am sending some data to another activity. And using this data populating a list using asynctask.

Then i count list items and sending it it previous activity using on backpressed.

@Override
    public void onBackPressed() {       
        Intent resultData = new Intent();
        resultData.putExtra("count", "45");
        setResult(Activity.RESULT_OK, resultData);
        finish();
    } 

When i press back button activity reload. Then again i am pressing back activity goes back.

On Activity result i am getting request code true. But when i am trying to get "data" of intent it will forceclose.

My main prob is that i am sending data as result of an activity and back button press twice.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire