Skip to content Skip to sidebar Skip to footer

Android Studio .code For Pass Data Between Two Edit Texts In Different Activities

I have made 3 activities first one is main and putted 2 button to pass to others pages through intent. I made intent between page 2 and page 3 for one Edit Text and it works good b

Solution 1:

It is because you are getting the string from activity 2 and when you go to activity 3 from the main activity it returns null, what you can do is to check if the bundle has empty string like this:

    Bundle bundle= getIntent().getExtras();
    if (bundle != null) {
       editText.setText (bundle.getString ("string"));
    }
    else {
       editText.setText ("Some string");
    }

Solution 2:

I use bundle for fragments but for activities try this:

Intentintent= getIntent();
editText.setText(intent.getStringExtra("nameofstring"));

Solution 3:

If your copy-paste is well, I think there is a comma missing here:

i.putExtra ("string"editText1.getText ().toString ());  

It should be:

i.putExtra ("string",editText1.getText ().toString ()); 

Post a Comment for "Android Studio .code For Pass Data Between Two Edit Texts In Different Activities"