在项目的页面跳转中,Activity启动顺序为:A—>B—->C——>A
其中A启动模式设置为Android:launchMode=”singleTask”
C通过intent传递参数给A,通过以下方式将无法获取,始终获取的是默认值。
@Override
protected void onStart(){
super.onResume();
isHome = getIntent().getBooleanExtra(ConfigConts.IsHome, false);
if (isHome) {
mainViewPager.setCurrentItem(0);
}
}
解决方法:
在A中重写onNewIntent()方法
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// must store the new intent unless getIntent() will return the old one
setIntent(intent);
}