我正在尝试打开新的Fragment并在推送(GCM)后从意图中加载一些数据,但是如果我


开启应用程式
打开消息片段
将应用程序推送到后台
推一下


我的应用程序已打开,打开了消息片段,但意图数据为空

 @Override
    protected void onMessage(Context context, Intent intent) {
...
  notificationIntent = new Intent(context, MainActivity.class);
//                            notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
//                                    Intent.FLAG_ACTIVITY_SINGLE_TOP);

                            notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
                                    Intent.FLAG_ACTIVITY_SINGLE_TOP);
                            notificationIntent.putExtra("param", "value");


我的活动打开时

getIntent().getExtras().getString("param") // is null


我该如何解决?请帮我弄清楚这个问题。

最佳答案

试试看

getIntent().getStringExtra("param");


代替

getIntent().getExtras().getString("param")

关于android - 还原 Activity 后,push getIntent为空,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25136009/

10-09 13:39