I want to parse SparseArray from one activity to other i tried many ways all not working
it's my last try SparseArray sa; after initialize and add data ....
Intent intent=new Intent(Main.this,Other.class);
intent.putExtra("sparsearray",(Serializable)sa);
StartActivity();
this code do so strange thing it return when go to this line intent.putExtra("sparsearray",sa); so if a toast under it toast never appear so strange really
Just wrap your SparseArray in a Bundle and it should work.
Intent intent = new Intent(context, Activity.class);
Bundle bundle = new Bundle();
bundle.putSparseParcelableArray("SPARSE_ARRAY_KEY",sparseArray);
intent.putExtra("BUNDLE_KEY", bundle);
to get the SparseArray back you will need to unwrap the Bundle again. Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.