有没有一种方法可以在onStop()立即回调活动?

时间:2020-01-12 06:31:22

标签: java android android-studio

我想创建一个无法停止的应用程序(发送到后台)。有没有办法做到这一点?这是我的代码

@Override
protected void onUserLeaveHint()
{
    Intent i = new Intent(this, DemoActivity.class);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.setAction(Intent.ACTION_MAIN);
    i.addCategory(Intent.CATEGORY_LAUNCHER);
    i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT & Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
    startActivity(i);
}

但是此代码没有立即响应,我在Everywehere搜索解决方案,但一无所获。谢谢。

0 个答案:

没有答案