button back date app

2

I have a main activity (MainActivity), which contains a list and a NavigationDrawer, when I click the register option this screen is called:

startActivity(new Intent(MainActivity.this, PessoasActivity.class));

And it works normally, but sometimes when I click on the option to return from the actionbar it closes the app, this happens more when I do the save the information in the database. When I click on the option to get back from the emulator and tmb on the device and close the app.

My AndroidManifest, MainActivity and Register (PeopleAcitivity) record:

<activity
        android:name="com.aplicacao.app.MainActivity"
        android:label="@string/app_name"
        android:noHistory="true" >
    </activity>
<activity
        android:name="com.aplicacao.app.PessoasActivity"
        android:label="@string/title_activity_pessoas" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.aplicacao.app.MainActivity" />
    </activity>

    
asked by anonymous 09.09.2014 / 03:33

1 answer

3

The problem is with the use of the noHistory="true" attribute. Removing it will solve the problem.

According to documentation , using this flag is the same as call finish when starting any Activity with the context of its MainActivity . As a result, MainActivity does not remain in BackStack , and when using back navigation, either through the button or the Home Indicator , MainActivity does not will be restored.

    
09.09.2014 / 03:51