Question

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");
Was it helpful?

Solution 2

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

OTHER TIPS

int s1 = b.getInt("depositeAmount");

Replace getString with getInt

int s1 = b.getInt("depositeAmount");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top