I am passing the bundle inside intent from one class to another. But while receiving it i am getting the error something like "readBundle: bad magic number". Here is a code snippet
Passing bundle from class A:
Intent intent = new Intent();
Bundle b1=new Bundle();
b1.putString("STORE_STATUS", "true");
b1.putParcelableArrayList("ParticularStoreInfo", particularStoreInfoArr);
intent.putExtra("BundleData", b1);
intent.setAction(Tag);
context.sendBroadcast(intent);
Receveing it in class B :
bundle = intent.getBundleExtra("BundleData");
if(bundle!=null){
String SEARCH_STATUS = bundle.getString("STORE_STATUS");// error on this line
if(SEARCH_STATUS.equalsIgnoreCase("true")){
}
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
String SEARCH_STATUS = bundle.getString("STORE_STATUS");
if (datas!= null) {
// do stuff
}
Edited:
And to send the data to the activity use this:
Intent intent = new Intent();
intent.putExtra("STORE_STATUS", "SOME DATAS");
Answer of your query:
To use Bundle to send data with your Intent you have to use this like:
Intent mIntent = new Intent(this, Example.class);
Bundle mBundle = new Bundle();
mBundle.extras.putString(key, value);
mIntent.putExtras(mBundle);