0

I know this is a common question and I apologize if I missed the answer to my problem but I tried a few things already and nothing seems to work.

The first codeblock writes arrays in a bundle and sends it via intent to the second activity but with getIntent() I get only an empty intent.

Intent playerstatsintent = new Intent(this, Save.class);
    Bundle allstats = new Bundle();
    allstats.putStringArray("EXTRA_NAMES", teams);
    allstats.putIntArray("PLAYER_STATS1", array1);
    allstats.putIntArray("PLAYER_STATS2", array2);
    allstats.putIntArray("PLAYER_STATS3", array3);
    allstats.putIntArray("PLAYER_STATS4", array4);
    playerstatsintent.putExtras(allstats);

    startActivity(playerstatsintent);

}

The second activity should get it like this:

Intent playerstatsintent = getIntent();
Bundle statisticsbundle = playerstatsintent.getExtras();


int[] playeronestats = statisticsbundle.getIntArray("PLAYER_STATS1");
int[] playertwostats = statisticsbundle.getIntArray("PLAYER_STATS2");
int[] playerthreestats = statisticsbundle.getIntArray("PLAYER_STATS3");
int[] playerfourstats = statisticsbundle.getIntArray("PLAYER_STATS4");

String[] opponents = statisticsbundle.getStringArray("EXTRA_NAMES");

I hope someone can help me because I dont see it.

Thanks, Demian

4

1 回答 1

0

感谢njzk2,我发现了我的错误。我没有在 onCreate 方法中调用 getIntent 。

于 2013-09-17T15:13:18.827 回答