android程序后台运行,但是程序并没有死亡,这时程序接到通知,点击通知,进入相应页面(这怎么实现)?
帮帮忙!!!
通过广播实现,注册广播监听,点击Notification时,发送广播
这是通知的点击事件
intent = new Intent(ContextReceiver.MESSAGE_RECEIVED_ACTION_ANNOUNCEMENT);
PendingIntent contentIntent = PendingIntent.getBroadcast(context, UUID.randomUUID().hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(contentIntent);
Notification notification_ = mBuilder.build();
manager.notify(NOTIFICATION_FLAG_ANNOUNCEMENT, notification_);
这是广播接收后,进行activity的跳转
intent.putExtra("type", type);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP );
context.startActivity(intent);
页面还是android的界面??html页面的话调后台接口。。android界面不太知道
我也不知道为什么,我改成了点击通知的时候,直接跳转activity(),而不用原来的先发广播,再跳转了
直接Notification打开Activity呀