これは私のコードです:
NotificationManager mNotificationManager = (NotificationManager) c.getSystemService(ns);
//Instantiate the notification
CharSequence tickerText = "Hello";
long when = System.currentTimeMillis();
Notification.Builder builder = new Notification.Builder(c)
.setTicker(tickerText)
.setWhen(when)
.setContentTitle("Test Notification")
.setContentText(arg1.getStringExtra("info"))
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true);
Notification notification = builder.getNotification();
mNotificationManager.notify(88, notification);
findは機能しますが、使用Notification notification = builder.getNotification();
は非推奨です。私がやるべきようにNotification notification = builder.build();
。問題は、Eclipseがそれを認識していないことです。つまり、コンパイルできません。build()
ドキュメントは存在し、その推奨される方法は明らかですが、私の側では機能していません。非推奨ではないコードを使用したいので、どんな助けでも大歓迎です。
輸入
import android.app.Notification;
import android.app.Notification.Builder;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.app.Notification.Builder;
使用されていないと言っていることに注意してください。