hcg_21 2013-07-12 01:57 采纳率: 0%
浏览 1903

不用停止服务器再启动一次来改变通知消息

这是我启动服务器时显示通知的方法:

private void showNotification() {
        Notification notification = new Notification(R.drawable.call, "Some text", System.currentTimeMillis());
        Intent intent = new Intent(this, MainActivity.class);

        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);
        notification.setLatestEventInfo(this, getString(R.string.notification_label), getString(R.string.notification_text_short), pi);
        notification.flags |= Notification.FLAG_NO_CLEAR;
        startForeground(7331, notification);
    }

一段时间后能改变 text 吗?比如 "Some text",我能否不用把服务器停止了然后再启动一次来改变它?

  • 写回答

1条回答 默认 最新

  • JaveZh 2013-07-12 02:09
    关注

    获取你的notification,然后设置内容,notify一下就可以改变

    评论

报告相同问题?

悬赏问题

  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?