判断从home键长按进入

int flag = mIntent.getFlags();
        if((flag & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY ) != 0) {
           startActivity(new Intent(this,SplashActivity.class));
           finish();
        }

PS:
  • HOME键的执行顺序:onPause->onStop->onRestart->onStart->onResume
  • BACK键的顺序:  onPause->onStop->onDestroy->onCreate->onStart->onResume
  • onPause不要做太耗时的工作

猜你喜欢

转载自yulincqupt.iteye.com/blog/1756699