-2

I have three Integers that are the index values of drawables in another file. Now that I have them in a bundle, how to I retrieve them from another activity? Below is code from the sending activity.

 Bundle b = new Bundle();
    b.putInt("headIndex", headIndex);
    b.putInt("bodyIndex", bodyIndex);
    b.putInt("legIndex", legIndex);

    final Intent intent = new Intent(this, AndroidMeActivity.class);
    intent.putExtras(b);

    Button btnNext = (Button) findViewById(R.id.btnNext);
    btnNext.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view){
            startActivity(intent);
        }
    });
  • 1
    Does this answer your question? [sending bundle to another activity](https://stackoverflow.com/questions/7815660/sending-bundle-to-another-activity) – Kasım Özdemir May 30 '20 at 21:53
  • your code is inconsistently indented ... the first line should be indented one more level so that it is the same as the second line – jsotola May 30 '20 at 21:56

1 Answers1

0

You can do this in the receiving activity

Intent intent = getIntent();
if (null != intent) { 
    int headIndex = intent.getIntExtra("headIndex");
    // Do this for remaining
}

Reference

Emmanuel Mtali
  • 2,242
  • 17
  • 38