在通知栏中看不到通知

时间:2013-10-09 13:27:14

标签: android notifications

我有一个错误,驱动器疯狂3天。 我想要做的是在通知栏上显示通知,这很简单,这是代码:

private void sendNotification(String msg) {
        mNotificationManager = (NotificationManager)
                this.getSystemService(Context.NOTIFICATION_SERVICE);

        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                new Intent(this, MainActivity.class), 0);

        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.ic_launcher)
        .setContentTitle("hello")
        .setStyle(new NotificationCompat.BigTextStyle()
        .bigText(msg + "1"))
        .setContentText(msg + "2");

        mBuilder.setContentIntent(contentIntent);
        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    }

在大多数设备中它运行正常,但在某些设备上(如galaxy1,android 4.1.2),它不会显示通知。

还有什么奇怪的是,当我用这个代码编写一个简单的应用程序时它可以工作,但是当我把这个代码放在我的应用程序中时(它几乎准备好生产并且有很多模块)它没有显示通知在通知栏上。

请帮助,任何想法?

1 个答案:

答案 0 :(得分:0)

令人尴尬的是,经过2天的研究,我们找到了解决方案。帮助我们找到解决方案的是我们更改了包名称并且工作正常。

之后我们意识到应用程序设置中的“允许通知”以某种方式关闭......

相关问题