5
我在機器人應用我想顯示多個通知逐個從activity.i新程序員已經實現的方法,以獲得通知如下如何從活動中逐一顯示通知警報列表?
public void myNotify(String message) {
Log.v("my notification method","from GetNotification class");
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon,
"check the notification", System.currentTimeMillis());
// Hide the notification after its selected
notification.flags |= Notification.FLAG_AUTO_CANCEL;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse(""));
PendingIntent activity = PendingIntent.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(this, message,
"for more info run ur app", activity);
notification.number += 1;
notificationManager.notify(0, notification);
}
和我已經使用一個字符串數組,以顯示通知作爲列表進行顯示的通知下面的代碼
String[] msg={"hai","how are you?","wer r u?","what is going on","how is this?","let we talk?","nothing is there","hahaha"};
Thread rt=new Thread(new Runnable() {
@Override
public void run() {
try {
for(int i1=0;i1<msg.length;i1++){
Log.v("", "thread running"+i1);
myNotify(msg[i1]);
Thread.sleep(5000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
rt.start();
從上面的代碼我想通過一個顯示通知的警報列表中的一個,如下所示:
海
你好嗎?
wer r u?
發生了什麼
這是怎麼回事?
........
我怎麼能顯示String數組值通知作爲名單