我将创建一个使用Google GCM服务的应用程序。
因此,我定义了以下函数:
@Override
protected void onMessage(Context context, Intent intent)
onMessage调用一个函数,这是代码的一部分:
Intent notificationIntent = new Intent(context,ShowMess.class);
notificationIntent.putExtra("id",current_id);
notificationIntent.putExtra("cat", cat);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(context, id, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
notificationManager.notify(id, notification);
如果我使用AsyncTask给自己发送一条消息,但很快关闭应用程序(使用返回按钮),那么下一条消息将不会启动ShowMEss.class活动。你认为为什么会这样?
再见。
谢谢。