【发布时间】:2012-08-30 12:21:31
【问题描述】:
我想知道如何在 android 中计算状态栏通知消息以及如何在我的活动停止时删除状态消息?任何代码 sn-p 都会被应用
【问题讨论】:
-
您是否尝试过实施这些答案?
标签: android
我想知道如何在 android 中计算状态栏通知消息以及如何在我的活动停止时删除状态消息?任何代码 sn-p 都会被应用
【问题讨论】:
标签: android
移除Activity的onDestory函数通知。
【讨论】:
您需要在关闭应用程序时清除它。这意味着,请拨打onDestroy。
如果您的通知类似于:
private static final int MY_NOTIFICATION_ID= 1234;
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager;
mNotificationManager = (NotificationManager) getSystemService(ns);
mNotificationManager.notify(MY_NOTIFICATION_ID, notification);
那么你需要实现以下来关闭它:
protected void onDestroy() {
super.onDestroy();
mNotificationManager.cancel(MY_NOTIFICATION_ID);
};
我从以下帖子中获取了这些信息:
Remove the notification icon from the status bar
http://developer.android.com/reference/android/app/Activity.html
【讨论】: