passing an array in intent android

2019-02-18 12:56发布

So I've always been under the assumption that you can't pass arrays between activities with extras. But I was just going through the Bundle class docs and saw putStringArray(String key, String[] value) and public String[] getStringArray (String key). Are these new? They both say since API lvl 1, but I don't remember being able to pass arrays. Am I going crazy here?

2条回答
贼婆χ
2楼-- · 2019-02-18 13:27

You can pass any Serializable object as extra, so I don't see why you could not pass String array. There is a setExtra(String, Serializable) method in the Intent, that's what I use.

查看更多
老娘就宠你
3楼-- · 2019-02-18 13:30

I think you must be able to pass string[] as a bundle in Android. Any specific reason you have for getting into such a conclusion?

Refer to this post

http://www.anddev.org/view-layout-resource-problems-f27/how-can-i-pass-multidimensional-string-array-two-activities-t9259.html

查看更多
登录 后发表回答