onActivityResult() and: failure delivering result resultinfo who=null request=1 result=-1 data=intent (has extras)

血红的双手。 提交于 2019-12-04 18:35:58

Try this way,hope this will help you to solve your problem.

There is two way send/get data to/from another activty

1.add data to intent.

how to put :

Intent newIntent = new Intent();
newIntent.putExtra("tag_grocery_foodItem", setFood);
newIntent.putExtra("tag_grocery_weight", setWeight);
newIntent.putExtra("tag_grocery_price", setPrice);
newIntent.putExtra("tag_grocery_brand", setBrand);
newIntent.putExtra("tag_grocery_category", setCategory);
setResult(RESULT_OK, newIntent);
finish();

how to get :

if(reqCode == ENTER_DATA_REQUEST_CODE && resCode == RESULT_OK){
   hkDBhelper.addItem(data.getStringExtra("tag_grocery_foodItem"),
   data.getStringExtra("tag_grocery_weight"),
   data.getStringExtra("tag_grocery_price"),
   data.getStringExtra("tag_grocery_brand"),
   data.getStringExtra("tag_grocery_category"));
   hkCursorA.changeCursor(hkDBhelper.listAll());
}

2.Add data to bundle and add bundle to intent.

how to put :

Intent newIntent = new Intent();
Bundle bundle = new Bundle();
bundle.putString("tag_grocery_foodItem", setFood);
bundle.putString("tag_grocery_weight", setWeight);
bundle.putString("tag_grocery_price", setPrice);
bundle.putString("tag_grocery_brand", setBrand);
bundle.putString("tag_grocery_category", setCategory);
newIntent.putExtras(bundle);
setResult(RESULT_OK, newIntent);
finish();

how to get :

if(reqCode == ENTER_DATA_REQUEST_CODE && resCode == RESULT_OK){
   hkDBhelper.addItem(data.getExtras().getString("tag_grocery_foodItem"),
   data.getExtras().getString("tag_grocery_weight"),
   data.getExtras().getString("tag_grocery_price"),
   data.getExtras().getString("tag_grocery_brand"),
   data.getExtras().getString("tag_grocery_category"));
   hkCursorA.changeCursor(hkDBhelper.listAll());
}

Your problem lies here:

activity {com.example.s188094_mappe3/com.example.s188094_mappe3.MainActivity}

Your package appears twice. It tries to open

com.example.s188094_mappe3/com.example.s188094_mappe3.MainActivity.class 

but that doesn't exist. Try cleaning your project, reopen Eclipse, all the good stuff.

And before you say anything i don't have enough reputation to comment.

If anyone has a better solution to this please replay.

Cheers!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!