pass array of values between two activities

android, android-intent

Solution

You are never adding the bundle to the Intent in Activity A. In addition, since you are passing an array of integers, you can add them directly to the intent. Like this:

intent.putExtra("myarray", array);
startActivity(intent);

Then you can easily retrieve it in Activity B like this:

int[] myIntArray = getIntent().getIntArrayExtra("myarray");

Problem

I have a problem to pass an integer array ​​between two activities. I tried this code: ActivityA: ``` Bundle myBundle = new Bundle(); myBundle.putIntArray("myarray", array); startActivity(intent); ``` ActivityB: ``` Bundle myBundle = getIntent().getExtras(); int[] myIntArray = myBundle.getIntArray("myarray"); ``` I don't understand why i can't use array values in activityB. Can you help me, please? Thanks

Original source

Related problems