String Not Passing To Second Android Activity
Solution 1:
You instantiate the string way too early, when creating the listener, instead, you should get it when the listener gets called:
@OverridepublicvoidonClick(View v) {
Intenti=newIntent( MyPowerSchoolActivity.this, creds.class);
i.putExtra("pschoolurl", EditTextURL.getText().toString());
// get the text here ^^^finalintresult=1;
startActivityForResult(i, result);
}
BTW, please follow the naming conventions and start variables with a lower-case letter (editTextURL) it will make the code less confusing for other people (like me :) )
Solution 2:
The value for url is getting set at instantiation time for your OnClickListener, before you have put any value into it. Try reading the value from your TextView in the body of the onClick method instead.
Solution 3:
Its notting wrong in your code just remove the String beside url in buttonsubmit.onclicklistener method. you dont have to startanactivity for result if u juat want to send a string from one activity to another. Thy this in your second activity.
Bundle b=getIntent().getExtras();
Stringurl= b.getInt("pschoolurl");
Solution 4:
check this out just put this code in your onclick of first activity Note:-> directly capture the edittext donot save the edit text in string and then pass it ,if you will do show then string will not pass. see the below example
publicvoidonClick(View v){
// TODO Auto-generated method stub
Intent i = newIntent(this,Web.class);
i.putExtra("epuzzle",urlenter.getText().toString());
finalint result = 1;
startActivityForResult(i, result);
}
now in second activity put this ,Note:-> is you will try to save the passeed string of activity first in to another string in activity second then it will not work ,you should directly pass the string to loadurl instead of saving and passing to loadurl.
Intentintent= getIntent();
w.loadUrl(intent.getExtras().getString("epuzzle"));
w.getSettings().setJavaScriptEnabled(true);
plz let me know if it worked for you or not.
Post a Comment for "String Not Passing To Second Android Activity"