How To Pass An Arraylist Between Two Intent In Android
I am new in Android and I have a question regarding intent. I want to pass an String ArrayList between two activities by using intent. I have tried this: ` ArrayList
Solution 1:
you can easily to by using Gson
Intent intent = newIntent(this,Game.class);
intent.putExtra("Player",newGson().toJson(playerName));
startActivity(intent);
at Game.class
ArrayList<String> playerNameList = playerNameList = newArrayList<>();
String str = getIntent().getStringExtra("Player");
playerNameList = newGson().fromJson(str,newTypeToken<ArrayList< String >>(){}.getType());
Post a Comment for "How To Pass An Arraylist Between Two Intent In Android"