【问题标题】:How to count status bar notification meesage in android & how to remove status message when my activity stop?如何在 android 中计算状态栏通知消息以及如何在我的活动停止时删除状态消息?
【发布时间】:2012-08-30 12:21:31
【问题描述】:

我想知道如何在 android 中计算状态栏通知消息以及如何在我的活动停止时删除状态消息?任何代码 sn-p 都会被应用

【问题讨论】:

  • 您是否尝试过实施这些答案?

标签: android


【解决方案1】:

移除Activity的onDestory函数通知。

【讨论】:

    【解决方案2】:

    您需要在关闭应用程序时清除它。这意味着,请拨打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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-24
      • 1970-01-01
      • 1970-01-01
      • 2019-10-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多