문제

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