Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. Intent intent = new Intent(context, ActivityB.class);
  2. intent.putExtra("my_value", 2); //2 is the value you want to pass
  3. startActivity(intent);
  4.  
  5. int variable = getIntent().getIntExtra("my_value", 0);//0 is the default value if the getintExtra doesn't find the "my_value"
  6.  
  7. Intent intent = new Intent(ActivityA.this,
  8. ActivityB.class);
  9. intent.putExtra("myInt", myInt);
  10.  
  11. getIntent().getIntExtra("myInt");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement