I've got this method in one class filling an Intent with data and then pass it back to the activity that started the method. Here I am using the intent to add the item to my database in onActivityResult()
But as the title indicates I'm getting an "failure delivering result resultinfo" error.
Can anyone see why I get this error?
Heres the essential part of my code:
from class 1, receiving the Intent :
@Override protected void onActivityResult(int reqCode, int resCode, Intent data){ super.onActivityResult(reqCode, resCode, data); 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()); } } Edit: added:
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.addItem) { startActivityForResult(new Intent(this, AddFood.class), ENTER_DATA_REQUEST_CODE); return true; } return super.onOptionsItemSelected(item); } And class 2, sending the Intnet:
public void addItem(){ setFood = itemFood.getText().toString(); setWeight = itemWeight.getText().toString(); setPrice = itemPrice.getText().toString(); setBrand = itemBrand.getText().toString(); setCategory = catagorySpinner.getSelectedItem().toString(); if(setFood.length() != 0 && setWeight.length() != 0 && setPrice.length() != 0 && setBrand.length() != 0 && setCategory.length() != 0){ Intent newIntent = getIntent(); 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); this.setResult(RESULT_OK, newIntent); finish(); } } And heres some lines from logcat:
10-29 09:28:23.569: E/AndroidRuntime(32565): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { cmp=com.example.s188094_mappe3/.AddFood (has extras) }} to activity {com.example.s188094_mappe3/com.example.s188094_mappe3.MainActivity}: java.lang.NullPointerException