我正在尝试直接从主活动创建通知。
这是我的代码 -
public class Notification extends Activity{
private static final int NOTIFY_ME_ID=1987;
private int count=0;
private NotificationManager mgr=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mgr=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
notifyMe();
}
public void notifyMe(){
Notification notification = new Notification(R.drawable.icon,
"Notification text that will be shown on status bar.",
System.currentTimeMillis());
// The PendingIntent will launch activity if the user selects this
// notification
PendingIntent contentIntent = PendingIntent.getActivity(Notification.this,
0, new Intent(Notification.this, MainActivity.class), 0);
notification.setLatestEventInfo(Notification.this, "Content Title", "Content text",
contentIntent);
mgr.notify(NOTIFICATION_ID, notification);
}
但我收到以下错误:构造函数 Notification(int, String, long) 未定义
我得到错误的行如下:
Notification notification = new Notification(R.drawable.icon,
"Notification text that will be shown on status bar.",
System.currentTimeMillis());