我正在Android Studio中工作并尝试在特定日期和时间生成通知。所有的都是正确的,但是,在我的服务类setLatestEventInfo()方法无法解析。 我在Eclipse中完成了相同的演示,并且没有任何eclipse问题。 我不想在任何按钮的点击或任何手动事件生成上生成通知,但会按照我指定的日期和时间生成通知。setLatestEventInfo()无法在Android Studio中解析
规范服务类如下:
public class MyRemiderService extends Service {
private NotificationManager mManager;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
@Deprecated
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
mManager = (NotificationManager) getApplicationContext()
.getSystemService(getApplicationContext().NOTIFICATION_SERVICE);
Intent intent1 = new Intent(this.getApplicationContext(),
HomeActivity.class);
Notification notification = new Notification(R.drawable.notification_template_icon_bg,
"This is a test message!", System.currentTimeMillis());
intent1.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingNotificationIntent = PendingIntent.getActivity(
this.getApplicationContext(), 0, intent1,
PendingIntent.FLAG_UPDATE_CURRENT);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.setLatestEventInfo(this.getApplicationContext(),
"AlarmManagerDemo", "This is a test message!",
pendingNotificationIntent);
mManager.notify(0, notification);
}
@Override
public void onDestroy() {
super.onDestroy();
}
请让我提供有关IT解决方案..谢谢。
哦~~ ..是否有任何替代关于它 ? –