How To Pass A 2 Dimention Array As An Intent Extra In Android
I pass 2d array [][] object as an intent extra to another activity, but its show error i can not be identifies what do i do? Bundle bundle = intent.getExtras(); S
Solution 1:
Intent.putExtra does not accept 2 dimension array as per the following document http://developer.android.com/reference/android/content/Intent.html
I have check the source code of Intent.putExtra , It use Bundle Class to store data
http://developer.android.com/reference/android/os/Bundle.html
Here is Source code of Intent.java
- Intent.java http://gitorious.org/android-eeepc/base/blobs/fda6fae156e31a287e3cfbf66e51ea1405cdf479/core/java/android/content/Intent.java
- Bundle.java https://github.com/android/platform_frameworks_base/blob/master/core/java/android/os/Bundle.java
Bundle.java use "HashMap" to store the content,
Best of my knowledge it's not possible directly
you can use putParcelable method, you need to create your own class instanceof 2 dimension array.
one quick solution
String[] keys = createKeys();
String[] values = createValues();
(keys.length == values.length)
bundle.putExtra("keys", keys);
bundle.putExtra("values", values);
Post a Comment for "How To Pass A 2 Dimention Array As An Intent Extra In Android"