我必须开发一个推送通知应用程序。
我喜欢 :
@Override
protected void onMessage(Context context, Intent intent) {
Log.i(TAG, "Received message");
GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
regId = GCMRegistrar.getRegistrationId(this);
String message = intent.getExtras().getString("offer");
displayMessage(context, message);
// notifies user
if(Constants.response != null){
generateNotification(context,message);
}
}
private static void generateNotification(Context context,String message) {
int icon = R.drawable.icon;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
Intent notificationIntent = new Intent(context, MyDealProducts.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent =
PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
}
这里通知在登录的客户上成功生成。
现在没有访问这些通知,同时注销了客户表单,这意味着我不需要启用通知。
但是这里通知已启用。注销客户后如何禁用通知?
请给我一个建议???