[ACCEPTED]-how do I restart an activity in android?-onresume
Accepted answer
This has been posted before:
Intent intent = getIntent();
finish();
startActivity(intent);
As of API level 11, you can 5 also just call an activity's recreate()
method. Not 4 only is this cleaner because it is less 3 code, it avoids issues that may arise if 2 your activity was launched by an implicit 1 intent.
Perhaps you could restart the activity as 7 has been demonstrated, but pass in some 6 intent extras to send your string back when 5 it re-starts.
Intent intent = getIntent();
intent.putExtra(STRINGTOSAVE, "Save this string");
finish();
startActivity(intent);
and in your onCreate you would 4 of course want to retrieve the string
Intent intent = getIntent();
String STRINGTOSAVE = intent.getStringExtra(ActivityName.STRINGTOSAVE);
and 3 then use the retrieved string to reapply 2 the textfield and any other actions you 1 need.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.