I have MainActivity with mapFragment inside of it. And I have settings button that starts new activity with settings.The following code starts it
@Override
public void onClick(View v) {
if(v == findViewById(R.id.btnSettings)){
Intent AlarmPreferencesActivityIntent;
AlarmPreferencesActivityIntent = new Intent(App.getContext(), AlarmPreferencesActivity.class);
AlarmPreferencesActivityIntent.putExtra("alarm", alarm);
App.getContext().startActivity(AlarmPreferencesActivityIntent);
}
}
Manifest declaration of activity
<activity
android:name=".Preferences.AlarmPreferencesActivity"
android:label="@string/title_activity_alarm_preference"
android:parentActivityName=".MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.geoalarm.MainActivity" />
</activity>
That settings activity has auto-generated back button in menu(you can see on screenshot).
So problem is when I press that button it doesn't return me back to MainActivity, but creates it again. Method onDestroy of MainActivity triggers when I press that back button in settings activity. Can I do something to get MainActivity by clicking back button that was created before I started activity with settings?