Using intent and bundle for integers in Android
问题 Say I wanted to pass data from one activity/class to the other involving an integer data type. Here's what I have for the MainActivity (first) class so far: @Override public void onClick(View v) { Intent i = new Intent(this, SecondActivity.class); final int x = 3; i.putExtra("new variable", x); startActivity(i); } For the receiving class, SecondActivity: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_second); Bundle i