passing int into android activities

Posted by Dawood Abbasi on Stack Overflow See other posts from Stack Overflow or by Dawood Abbasi
Published on 2012-10-06T09:31:27Z Indexed on 2012/10/06 9:37 UTC
Read the original article Hit count: 290

Filed under:
|

i pass int to next activity using this code

Intent intent = new Intent(A.this, B.class);    
intent.putExtra("selectedType", i);    
startActivity(intent);

and then receive this in activity B

Intent intent = new Intent();
int i = intent.getIntExtra("selectedType", 0);
Toast.makeText(getApplicationContext(), String.valueOf(i),
Toast.LENGTH_LONG).show();

but when in this activity, it always display 0.

© Stack Overflow or respective owner

Related posts about android

Related posts about android-activity