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,545
  • 1
  • 24
  • 32

3 Answers3

2
int s1 = b.getInt("depositeAmount");
Hardik Joshi
  • 9,427
  • 12
  • 60
  • 113
Sino
  • 866
  • 7
  • 20
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
  • 132
  • 1
  • 15
0

Replace getString with getInt

int s1 = b.getInt("depositeAmount");
Hardik Joshi
  • 9,427
  • 12
  • 60
  • 113
d.danailov
  • 9,278
  • 4
  • 49
  • 35