How To Pass Variables From A New Intent Back To The Class That Created It In Android
I know my title may be a little convoluted but I am really quite confused and couldn't think of a better title. My problem: I have a main class that creates a new intent. This new
Solution 1:
What you will need to do is a combination of things.
First, start the activity using:
Intentintent=newIntent("com.stevedub.GS.INPUTMPG");
startActivityForResult(intent, RETURN_CODE);
Then in your InputMPG class, set the Return value with the following:
IntentreturnIntent=newIntent();
returnIntent.putExtra("result", editText.getText());
setResult(RESULT_OK, returnIntent);
Finally to receive the data in your original Activity use the onActivityResult method:
publicvoidonActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RETURN_CODE && resultCode == RESULT_OK) {
//get value from intent
}
}
Solution 2:
Try to use startActivityForResult()
Post a Comment for "How To Pass Variables From A New Intent Back To The Class That Created It In Android"