I invoke activity through:

Intent i = new Intent(MainActivity.this, InputData_DialogActivity.class); i.putExtra("currently page", currentlyPage); startActivity(i); 

And then, in the second activity I get Extra through:

  int currentlyPage = this.getIntent().getIntExtra("currently page", 0); 

And as a result I get the value 0 (although I give 3, I checked)!


What am I doing wrong?

    1 answer 1

    Try to put the values ​​in the Bundle first, then the bundle into the intent.

    Take it out like this:

     Intent.getExtras().getInt("key", 0); 
    • Removed the space - it did not help. - user189127
    • But how to do it? O. By the way, the string transmits even with a space. - user189127
    • Bundle b = new Bundle (); b.putInt ("key", value); i.putExrtas (b); Try not to transfer a variable but simply a number, in numbers. You seem ochepatka somewhere again. - JuriySPb
    • I mean, you see, you didn’t keep track of the value of the variable) - YuriiSPb
    • Now I’ll try to pass by number to find the "occult", and then I will try through Bundle (although it will be more economical to convert the string to a number ...). - user189127