【发布时间】:2011-07-16 10:22:08
【问题描述】:
他,我是android平台的新手。
现在我正在开发一个基于通知的小应用程序。
在我的应用程序中,每次显示通知时,我都会根据该时间维护一个计时器。
但问题是第一次显示通知,第二个通知附加在第一个通知上方,第三个通知附加在第二个通知上方........
我想一一显示通知。
如果有人知道如何一一显示通知。请回复我。
这是我的代码
myTimer = new Timer();
myTimer.schedule(new TimerTask()
{
@Override
public void run()
{
TimerMethod();
}
}, 10000,10000);
}
private void TimerMethod()
{
this.runOnUiThread(Timer_Tick);
}
private Runnable Timer_Tick = new Runnable()
{
public void run()
{
mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
final Notification notifyDetails = new Notification(R.drawable.icon,"New Alert, Click Me!",System.currentTimeMillis());
Context context = getApplicationContext();
CharSequence contentTitle = "Notification Details...";
CharSequence contentText = "you have a new notification find clicking me";
Intent notifyIntent = new Intent(Notifi.this,Notifi.class);
PendingIntent intent =
PendingIntent.getActivity(Notifi.this, 0,
notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
notifyDetails.setLatestEventInfo(context, contentTitle, contentText, intent);
mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);
}
};
提前致谢
【问题讨论】:
标签: android notifications