intent.getStringExtra() returns null
in HomeActivity
you are initializing intent as
intent = Intent()
This actually initializes the intent with a new intent object. That is not desired behavior, to achieve desired behavior use getIntent()
instead of Intent()
.
Android intent.getStringExtra() return null
if(resultCode == 0){
//Intent intent = getIntent();
String name2 = data.getStringExtra("namev");
String email2 = data.getStringExtra("emailv");
String birthday2 = data.getStringExtra("birthdayv");
Log.d("AAA",">>>:"+name2);
Contact person = new Contact(name2,email2,birthday2);
allContact.add(person);
}}
you need to use the data not getIntent()
Android Intent.getStringExtra() returns null
When you insert your Extras
trying adding .toString()
i.putExtra("Name", edt_name.getText().toString());
You are seeing the CharSequence
value in there but you need to convert it to a String
to call getStringExtra()
. Obviously, just do this for the Strings
. You see the correct value for your int
because that is done correctly
Getting null value for Intent.getstringExtra()
Move this code inside onCreate
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout);
Intent wb = getIntent();
final String url = wb.getStringExtra("link");
if (savedInstanceState == null) {
webView.post(() -> webView.loadUrl(url));
}
}
intent.getStringExtra is always null
You are creating a brand new intent in the other activity, so it has no extras. In the new activity you need to call getIntent()
, like this
Intent intent = getIntent(); // don't use 'new Intent()' here
String username = intent.getStringExtra("username");
Log.i("test3","username: "+username);
Note that calling getStringExtra
just calls getExtras()
internally, then getString(...)
, so it is the same as using getIntent().getExtras().getString(...)
Related Topics
Javadoc in Eclipse Failing to Recognize Packages
How to Change the Led Intensity of an Android Device
Android Studio: Duplicate Files Copied in APK Meta-Inf/Dependencies When Compile
Android Volley to Handle Redirect
Firebase Onmessagereceived Not Called When App Is in the Background
Mediarecorder Start Failed: -38
Retrieve String Out of Addvalueeventlistener Firebase
View the Task's Activity Stack
A Failure Occurred While Executing Org.Jetbrains.Kotlin.Gradle.Internal.Kaptexecution
Proguard Ignores Config File of Library
Android Studio Fails to Build New Project, Timed Out While Wating for Slave Aapt Process
How to Filter Listview Data When Typing on Edittext in Android
How to Hide Toolbar When I Scrolling Content Up
Android: Notifydatasetchanged(); Not Working
Android Bluetoothdevice.Getname() Return Null