문제

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");
도움이 되었습니까?

해결책 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

다른 팁

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

Replace getString with getInt

int s1 = b.getInt("depositeAmount");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top