这是我启动服务器时显示通知的方法:
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",我能否不用把服务器停止了然后再启动一次来改变它?
获取你的notification,然后设置内容,notify一下就可以改变