0

Getting Value in Bundle but when placed that bundle value in string it is showing null value.here is my code:

Activity:1

    public void btnDeposite(View v)
{
     s1 = e1.getText().toString();
    amt1 = Integer.parseInt(s1);

    Intent i =new Intent(this,Transfer.class);
    i.putExtra("depositeAmount", amt1);
    startActivity(i);
}

Activity:2

//in onCreate()

       b = getIntent().getExtras();
       s1 = b.getString("depositeAmount");
Madhu
  • 2,565
  • 2
  • 25
  • 32

3 Answers3

2
int s1 = b.getInt("depositeAmount");
Hardik Joshi
  • 9,477
  • 12
  • 61
  • 113
Sino
  • 886
  • 7
  • 21
1

This is Because you are changing amt1 into int

s1 = e1.getText().toString();
amt1 = Integer.parseInt(s1);

and getting the value as a String

s1 = b.getString("depositeAmount");

Change it to

s1 = b.getInt("depositeAmount");

Hope this Helps.!!

Thanks

Mohit Rakhra
  • 114
  • 1
  • 15
0

Replace getString with getInt

int s1 = b.getInt("depositeAmount");
Hardik Joshi
  • 9,477
  • 12
  • 61
  • 113
d.danailov
  • 9,594
  • 4
  • 51
  • 36