I want to pass a string from 1 activity to another, although I have taken reference from many accepted answers from other threads, I am facing problem that I am not able to debug. When I comment extras.putString as shown in code below, Toast message shows the correct address which means value is being set properly and code works fine but when I use extras.putString(), I get NullPointerException and application closes due to exception. There are many characters in my address string. Infact even if I use extras.putString("userAddress", "test") I get NullPointerException
在此,我的主要活动是我所说的“FBShare活动”:
Intent mIntent = new Intent(this, FBShare.class);
Bundle extras = mIntent.getExtras();
String currentAddress = getCurrentAddress(ourLocation);
Toast.makeText(getBaseContext(), getCurrentAddress(ourLocation), Toast.LENGTH_SHORT).show();
extras.putString("userAddress", currentAddress);
startActivity(mIntent);
And in FBShare Activities 我试图 follows取以下价值观:
strAddress = getIntent().getExtras().getString("userAddress");