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 \n characters in my address string. Infact even if I use extras.putString("userAddress", "test") I get NullPointerException
Here is my Main Activity from which I want to call FBShare Activity:
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 Activity I am trying to fetch values as follows
strAddress = getIntent().getExtras().getString("userAddress");
Here is one thread which is doing similar thing.