I have two activity and I want to pass ArrayList -> drawablesFromUrl objs from activity A to activity B. Parts of the code is listed as follow:
In Activity A:
Intent i = new Intent(getApplicationContext(),SitePhotoFullScreen.class);
Bundle myData = new Bundle();
myData.putInt("id", position);
myData.putInt("MaxId", imgAdapter.getCount());
myData.putSerializable("myObjArray",drawablesFromUrl);<---- this objs
i.putExtras(myData);
startActivity(i);
In Activity B
ArrayList<Drawable> myObjArray = new ArrayList<Drawable>();
// get intent data
Intent i = getIntent();
Bundle myBundle = i.getExtras();
position = myBundle.getInt("id");
MaxId = myBundle.getInt("MaxId");
myObjArray = (ArrayList<Drawable>) i.getSerializableExtra("myObjArray");
After execute the code, an error occur :
AndroidRuntime(15005): java.lang.RuntimeException: Parcel: unable to marshal value android.graphics.drawable.BitmapDrawable@4052d928
Anyone can help me to solve the problem, thousand thanks!
Pass your object via
Parcelable. Here is a link that will show you how to do that with relative ease:http://shri.blog.kraya.co.uk/2010/04/26/android-parcel-data-to-pass-between-activities-using-parcelable-classes/