android点击后退退出rencent,Android:如果从Recent Task启动应用程序,则Activity正在使用旧意图...

我正在实施GCM . 我的应用程序有两个活动,比如 A 和 B . 我正在使用此代码从NotificationBar启动 B :

long when = System.currentTimeMillis();

NotificationManager notificationManager =

(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

String title = context.getString(R.string.app_name);

Notification notification = new Notification(R.drawable.app_notification_icon, "De Centrale", when);//message

Intent notificationIntent = new Intent(context, B.class);

notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); //|Intent.FLAG_ACTIVITY_REORDER_TO_FRONT

PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);

notification.setLatestEventInfo(context, title, msg, intent);

notification.flags |= Notification.FLAG_AUTO_CANCEL;

notificationManager.notify(0, notification);

NotificationBar用Intent打开Activity B ,比如'B-notification-intent',然后我使用Back按钮从 B 打开Activity A ,然后我再次从具有新Intent(例如'B-A-intent')的 A 启动 B . 我使用下面的代码:

intent = new Intent(this, B.class);

intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

startActivity(intent);

然后我在 B 中获得了新数据(即刷新了 B 的屏幕) . 但是,如果我按下主页按钮,然后我从最近的应用程序启动应用程序,那么我会使用'B-notification-intent'获得更长的 B 屏幕 . 相反,我想要最新的意图,即'B-A-intent' . 我在 B 中使用此代码:

@Override

protected void onCreate(Bundle b)

{

fetchDataFromDB(getIntent());

}

@Override

protected void onNewIntent(Intent intent)

{

fetchDataFromDB(intent);

}

所以任何人请帮助我获取当前的屏幕(意图) .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值