1、独立编写产生Notification 的方法
private static int NOTIFICATION_ID=R.layout.main;
public void GreateNotification (){
NotificationManager notificationManager=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.sun, "天气预报", System.currentTimeMillis());
PendingIntent contentIntent = PendingIntent.getActivity(this, 1, new Intent(), 1);
notification.setLatestEventInfo(this, "title", "content", contentIntent);
notificationManager.notify(NOTIFICATION_ID, notification);
}
2、在需要产生Notification 的地方调用以上方法。
3、取消Notification 的方法:
public void CanllNotification (){
notificationManager.cancel(NOTIFICATION_ID);
}
private static int NOTIFICATION_ID=R.layout.main;
public void GreateNotification (){
NotificationManager notificationManager=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.sun, "天气预报", System.currentTimeMillis());
PendingIntent contentIntent = PendingIntent.getActivity(this, 1, new Intent(), 1);
notification.setLatestEventInfo(this, "title", "content", contentIntent);
notificationManager.notify(NOTIFICATION_ID, notification);
}
2、在需要产生Notification 的地方调用以上方法。
3、取消Notification 的方法:
public void CanllNotification (){
notificationManager.cancel(NOTIFICATION_ID);
}