直接上代码
Manifest
<activity
android:name=".module.comman.CloseActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Activity
public class CloseActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_close);
startActivity(new Intent(this, SplashActivity.class));
//startActivity(new Intent(this, LoginActivity.class));
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
finish();
}
}
使用
startActivity(new Intent(this, CloseActivity.class))
BUG
启动页为singleTask时,HOME键回到桌面再次点击图标会重启应用,最近列表回到应用无影响.
ps.有类似推送新开栈自己处理
网友评论