Вопрос

When I click my app's icon on the desktop,the splashactivity will first run, then it start the loginactivity before it finished. I click the loginbutton to login.then I came to the mainactivity.Then I click the HomeKey to goto the Android Home. At this time ,I click the app's icon again, the splashactivity start firstly. Why the mainactivity can't be recover? Othewirse,when I click the HomeKey at loginactivity ,the app can skip the splashactivity and recover the loginactivity.Thanks.

Это было полезно?

Решение

Thats very unusual, when a home key is pressed, an app is usually restored in the state it was left. At least thats what i have seen with all apps i have on my phone. What you could do is control your app flow using onPause() and onStop() as they get called when HomeKey is pressed.

Другие советы

If you create your LoginActivity as the launch activity, then you can display SplashActivity only when you want to display it. My recommendation was being once a day.

In the onStart of your LoginActivity:

@Override
protected void onStart()
{
    /* 
        get last stored time & date of onStart using SharedPreferences
        get the current time & date

        if (current day != stored day)
            store date and time
            startActivity(SplashActvity)
    */
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top