| public void addOngoingNotify(){NotificationCompat.Builder mBuilder = new Builder(this);RemoteViews mRemoteViews = new RemoteViews(getPackageName(), R.layout.view_notify);
mRemoteViews.setImageViewResource(R.id.notify_ongoing_icon_1, R.drawable.notify_ongoing_icon_2);
mRemoteViews.setTextViewText(R.id.txt_label, “遠圖未來”);
mRemoteViews.setViewVisibility(R.id._notify_button, View.VISIBLE);
mRemoteViews.setImageViewResource(R.id.btn_notify_1, R.drawable.btn_notify_2);
//按鈕動作處理
Intent buttonIntent = new Intent(ACTION_BUTTON);
buttonIntent.putExtra(INTENT_BUTTONID_TAG, BUTTON_PREV_ID);
PendingIntent intent_prev = PendingIntent.getBroadcast(this, 1, buttonIntent, PendingIntent.FLAG_UPDATE_CURRENT);
mRemoteViews.setOnClickPendingIntent(R.id.btn_notify_1, intent_prev);
mBuilder.setContent(mRemoteViews)
.setContentIntent(getDefalutIntent(Notification.FLAG_ONGOING_EVENT))
.setSmallIcon(R.drawable.notify_ongoing_icon_2)
.setPriority(Notification.PRIORITY_DEFAULT)
.setWhen(System.currentTimeMillis())
.setTicker(“常駐通知@蓄豐實驗艙”)
.setOngoing(true);
Notification notify = mBuilder.build();
notify.flags = Notification.FLAG_ONGOING_EVENT;
mNotificationManager.notify(notifyId, notify);
} |