私はHoneycomb用に開発しており、この問題を解決しようとしています。 私は意志なしで通知サービスを持っています(問題はありません)、問題は、毎回ディスプレイメッセージの呼び出しが毎回通知の機能を果たしているので、100通の通知を得ることです。私は一度だけポップアップしたいと思っていますし、パーセントのテキストを変更するだけです。マーケットプログレスバーとパーセンテージからのダウンロードと同様です。私は機能を分離し、新しいテストコードを作成しましたが、成功しませんでした。これを他の角度から見ると、新しい通知を作成せずに既存の通知のテキストを変更したいと考えています。 私を助けてもらえますか?ここAndroid Honeycomb通知ポップアップが頻繁に発生する
は(単離後)全体コードである:
package com.disp;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Bundle;
import android.os.SystemClock;
public class DispalyActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
for (int i = 0; i < 100; i++) {
SystemClock.sleep(300);
displaymessage(""+i+"%");
}
}
public void displaymessage(String string) {
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
Notification notification = new Notification(R.drawable.ic_launcher, "Notification Service", System.currentTimeMillis());
Context context = getApplicationContext();
notification.setLatestEventInfo(context, "Downloading Content:", string, null);
final int HELLO_ID = 2;
mNotificationManager.notify(HELLO_ID, notification);
}
}