Reputation: 55
I have a small app, then when I get out of the app (minimizo) and open again, it starts with the application of the home screen instead of opening the page you left off. That is, it starts the application all over again when it is minimized.
<?xml version="1.0" encoding="utf-8"?>
package="com.example.kevin.estudosbiblicos" >
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/app_name">
</activity>
<activity android:name=".Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Upvotes: 0
Views: 2923
Reputation: 263
First, you need to finish the splash activity after starting mainActivity.
new Timer().schedule(new TimerTask() {
public void run() {
Intent intent = new Intent();
intent.setClass(Splash.this, MainActivity.class); //Chamando a classe splash e a principal (main)
startActivity(intent);
finish();
}
}, 2000);
And in mainActivity , can you call finish() method in onpause method. please show the whole mainActivity code
and you shouldn't use finish in onpause in your activity.
Upvotes: 2
Reputation: 3401
<activity ...
android:alwaysRetainTaskState="true"/>
Do this for all activities you want to save the state.
Upvotes: 0