您好,登錄后才能下訂單哦!
// 在用戶離線時,設(shè)備發(fā)送的消息保存在服務(wù)器
// 當用戶上線時,向服務(wù)器發(fā)送命令,服務(wù)器把離線消息發(fā)送給手機端
// 所有消息以通知的形式顯示
@SuppressWarnings("deprecation")
private void showNotification(int eventType, String msgType) {
try {
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
//
// Intent intent = new Intent(this, EventListActivity.class);
Intent intent = new Intent(this, OfflineWarnningActivity.class);// 這里是點擊通知后
// 跳轉(zhuǎn)的activity
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
long time = (Integer.parseInt(GCMBroadcastReceiver.eventTimeString) - 8*60*60) * 1000L;
String msg = "離線推送消息";
Notification notification = new Notification(R.drawable.nty_alert,
msg, time);
notification.icon = R.drawable.icon;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
// notification.flags |= Notification.FLAG_NO_CLEAR;//這條語句控制通知是否可以刪除
notification.defaults = Notification.DEFAULT_ALL;
notification.setLatestEventInfo(this, String.format(msg, msgType),
String.format(getText(R.string.ntfLastEventIs).toString(),
msgType), pendingIntent);
manager.notify(1, notification);
} catch (Exception e) {
e.printStackTrace();
}
}
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。