1

I have a bug that drive be crazy for 3 days. What im trying to do is show a notification on the notification bar, which is very simple, this is the code:

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());
    }

In most of the devices is it working ok, but on some devices (like galaxy1, android 4.1.2) it does not show the notification.

What else is weird is that when i write a simple application with this code it works, but when i put this code in my application (which is almost ready for production and has a lot of modules) it does not show the notification on the notification bar.

Please help, any ideas?

4

1 回答 1

0

it is embarrassing to say that after 2 days of research we found the solution. What helped us find the solution is that we changed the package name and it worked.

Afterwards we realized that this the "allow notifications" in the application settings was somehow turned off...

于 2013-10-10T03:20:39.980 回答