Android Intent.getstringextra() Return Null
MainActivity public class MainActivity extends AppCompatActivity { private static final int REQ_CODE_TO_ADD = 123; final ArrayList allCon
Solution 1:
if(resultCode == 0){
//Intent intent = getIntent();Stringname2= data.getStringExtra("namev");
Stringemail2= data.getStringExtra("emailv");
Stringbirthday2= data.getStringExtra("birthdayv");
Log.d("AAA",">>>:"+name2);
Contactperson=newContact(name2,email2,birthday2);
allContact.add(person);
}}
you need to use the data not getIntent()
Solution 2:
You are using the Intent which originally launched the Activity. Use the Intent which was sent as a parameter instead.
Solution 3:
There's no need for
Intentintent= getIntent();
Intent is already passed as argument i.e 'data'
Use this variable to extract data. Hope this helps.
Solution 4:
Intentintent= getIntent(); // This line is wrongStringname2= intent.getStringExtra("namev");
Stringemail2= intent.getStringExtra("emailv");
Stringbirthday2= intent.getStringExtra("birthdayv");
Modify your code like this
if(requestCode==2 && resultCode==RESULT_OK){
Bundle bundle=data.getExtras();// here "data" is your intentStringstring=bundle.getString("message");
Log.i(TAG,"onActivityResult Called..."+string);
}
Post a Comment for "Android Intent.getstringextra() Return Null"