0
我正在爲Android創建一個應用程序,它沒有在市場上列出,所以我創建了自己的更新程序。發出通知很慢?
一個的AsyncTask在後臺運行,檢查是否有新版本, 當有它創建了一個通知
當通知是在狀態欄,打開狀態欄是緩慢的(有時點擊一個新版本?在通知不會工作)
這裏是我的代碼:
public static void makeNotification(Class<?> newclass, CharSequence msg, CharSequence from, CharSequence message, int icon, Context c) {
PendingIntent newintent = PendingIntent.getActivity(c, 0, new Intent(c, newclass), 0);
NotificationManager nm = (NotificationManager) c.getSystemService(NOTIFICATION_SERVICE);
Notification notif = new Notification(icon, msg, System.currentTimeMillis());
notif.setLatestEventInfo(c, from, message, newintent);
nm.notify(0, notif);
}
這是主要活動,並得到來自所謂的AsyncTask。
if (Integer.parseInt(xmlroosters.getVersionCode()) > currentversion){
new Main().makensNotification(Update.class, "The app need an update.", "Update", "Click here to update the app.", R.drawable.app);
}
有人能告訴我爲什麼這很慢嗎? (有時我甚至不能打開狀態欄) 以及爲什麼有時點擊它甚至不可能?
請問一個運行的AsyncTask不止一次? – WHDeveloper 2013-02-09 13:07:25
通知的代碼在if循環中 - >檢查已編輯的問題 – WHDeveloper 2013-02-09 13:08:56
不,但它是如何坐在那裏等待更新的? AsyncTask()包含一個循環,用於觀察更新? – 2013-02-09 13:11:22