android - 如何以编程方式更改通知栏中的应用程序名称
问题描述
我想在通知栏中更改应用程序名称,但找不到简单的解决方案。他们说必须更改应用程序名称。我找到了这个库。
https://github.com/myinnos/AppIconNameChanger
但是太麻烦了。每次更改需要 10 秒。没有机会通过简单的解决方案仅更改通知栏中的应用程序名称吗?
这是我的通知示例代码
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this.getApplicationContext(), "notify_001");
Intent ii = new Intent(this.getApplicationContext(), MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, ii, 0);
NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle();
bigText.bigText("Big text");
bigText.setBigContentTitle("Big content title");
bigText.setSummaryText("summary text");
mBuilder.setContentIntent(pendingIntent);
mBuilder.setSmallIcon(R.drawable.ic);
mBuilder.setContentTitle("Content Title");
mBuilder.setContentText("Content text");
mBuilder.setPriority(Notification.PRIORITY_MAX);
mBuilder.setStyle(bigText);
NotificationManager mNotificationManager =
(NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel("notify_001",
"Channel human readable title",
NotificationManager.IMPORTANCE_DEFAULT);
mNotificationManager.createNotificationChannel(channel);
}
mNotificationManager.notify(0, mBuilder.build());
解决方案
您需要使用 setContentTitle 来更改标题。
推荐阅读
- powershell - 尝试使用 Powershell 消除我们使用的软件的不需要的安装。(GUID)
- apache-spark - spark repartition / executor inconsistencies commandline vs jupyter
- python - 没有重叠单词的句子的 Fuzzywuzzy 分数高于那些有一些重叠的句子?
- r - 使用条件将列更改为单独的数据框
- json - 未在 Wikidata 或 DBpedia 上的 Wikipedia 表数据的 JSON,下一步?
- php - MySQL全文搜索修改,任意顺序搜索词
- c# - 将 XML 转换为 JSON 到 c# 对象
- ruby-on-rails - 为 Rails 创建简单的站点密码 - 没有用户名
- javascript - 当我登录并导航到新屏幕时,UI 冻结。一旦我刷新应用程序,屏幕就会工作。知道为什么吗?
- node.js - 如何从angular4组件传递参数来表达API