发送通知,为什么通知栏显示的是项目名,而不是应用名?

新手发帖,不知道附件图片能不能直接显示。通知栏的一条信息大概是这样的:
icon    应用名
        信息标题
        信息内容....

我现在发的通知应用名的地方显示的是项目名,一串英文字母。而我把bundle name 和 bundle display name都改成汉字了。可通知栏上仍然是英文的项目名,新人求解啊

我还需要改什么东西么? 
图片:QQ20150409-1.png 
已解决。
原来是因为最开始真机调试时的名字是项目名,手机应该是记录下app ID了,后来删除重装也没用。
但是在从没跑过的真机上运行,通知栏显示的就是我后来设置的中文名。 
有。其实很简单,删除应用,重启手机,再跑出来就好了。 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要实现Android Service常驻后台且应用杀死后仍能发送通知消息,可以按照以下步骤进行: 1. 在Service中通过startForeground()方法将Service设置为前台Service,同时在通知显示一个通知。 2. 在Service中使用AlarmManager定时发送通知消息,即使应用被杀死也能够执行定时任务,代码示例如下: ``` AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(this, NotificationService.class); PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 60 * 1000, pendingIntent); ``` 3. 创建一个NotificationService,用于接收AlarmManager发送通知消息,代码示例如下: ``` public class NotificationService extends Service { private static final int NOTIFICATION_ID = 1; @Override public int onStartCommand(Intent intent, int flags, int startId) { showNotification(); return super.onStartCommand(intent, flags, startId); } private void showNotification() { NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification.Builder(this) .setContentTitle("这是通知标题") .setContentText("这是通知内容") .setSmallIcon(R.mipmap.ic_launcher) .setAutoCancel(true) .build(); notificationManager.notify(NOTIFICATION_ID, notification); } @Nullable @Override public IBinder onBind(Intent intent) { return null; } } ``` 需要注意的是,AlarmManager定时发送通知消息的时间间隔应该根据实际需求进行调整。同时,如果不再需要Service常驻后台,应该通过stopForeground(true)方法将其设置为普通Service,并且应该取消之前设置的定时任务,以免浪费系统资源。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值