I have a child activity that updates the database, which is shown in a table below in the parent activity. When the parent activity (Update) is done, a commit is send to the database and the data will be updated. Afterwards I would like to close Update and go back to my parent activity Display. This works, but the data is not refreshed. I read online that there is a simple method to recreate an activity..
public void recreate ()
Cause this Activity to be recreated with a new instance. This results in essentially the same flow as when the Activity is created due to a configuration change -- the current instance will go through its life cycle to onDestroy() and a new instance then created after it.
So I call the UpdateActivity from the DisplayActivity with:
Intent intent = new Intent(app, UpdateActivity.class);
startActivity(intent);
And within the Update there is a button that does:
getParent().recreate();
finish();
However getParent() returns null and I get an error. Why is that?
I have the following in my AndroidManifest.xml (Ofc. more but did not list everything)
<activity
android:name=".SearchActivity"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".DisplaySearchResultActivity"
android:screenOrientation="landscape"
android:parentActivityName=".SearchActivity">
</activity>
<activity
android:name=".UpdateActivity"
android:parentActivityName=".DisplaySearchResultActivity"
android:screenOrientation="portrait">
</activity>
Thanks.