获取不到intent传递的数据

来源:互联网 发布:linux grep 完全匹配 编辑:程序博客网 时间:2024/05/22 14:21

在项目的页面跳转中,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);     }  
0 0