I am sending data in hashmap back to parent activity from child acitvity
here is my code Child activity
private void sendDataToPrevPg(HashMap<String, String> hm) {
// Send to previous activity page
Bundle bndle = new Bundle();
bndle.putSerializable("stockList", (Serializable) hm);
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("stkList",bndle);
setResult(RESULT_OK, intent);
this.finish();
}
In parent
@SuppressWarnings("unchecked")
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK ) {
if (data.hasExtra("stkList")) {
Bundle wrapper = getIntent().getBundleExtra("stkList");
HashMap<String, String> myClass3 = (HashMap<String, String>) wrapper.getSerializable("stkList");
System.out.println("...serialized data4.."+myClass3);
}
}
}
showing error at line
HashMap<String, String> myClass3 = (HashMap<String, String>) wrapper.getSerializable("stkList");
Logcat:: Caused by: java.lang.NullPointerException
how to send data in hashmap? to parent activity