Activity设置singleTask无法通过Intent获取值的问题

在项目的页面跳转中,Activity启动顺序为:A—>B—->C——>A

其中A启动模式设置为android:launchMode=”singleTask” ,

当C跳转到A时,A将不再执行onCreate方法,而是直接执行onResume;

C通过intent传递参数给A,通过以下方式将无法获取。

[html] view plaincopy在CODE上查看代码片派生到我的代码片

@Override  
protected void onResume() {  
    super.onResume();  
    Bundle bundle = getIntent().getExtras();  
    if (null != bundle) {  
        trande_Amount = bundle.getString("Amount");  
    }  
}  

解决方法:

[html] view plaincopy在CODE上查看代码片派生到我的代码片

protected void onNewIntent(Intent intent) {  
       super.onNewIntent(intent);  
       // must store the new intent unless getIntent() will return the old one  
       setIntent(intent);  
   }  

原文链接:http://blog.csdn.net/lvxiangan/article/details/43084633

你可能感兴趣的:(Android)