Notification not coming from an Android service
<p>I have a service class that receives message from server and I should notify the user about the message. I got this code from internet for showing notification -</p>

<pre><code>public void showNotification(String msg){
        logger.debug("GOT NEW TEXT MESSAGE0: " + msg);
        Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

        Intent intent = new Intent(this, NotificationReceiver.class);

        PendingIntent pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);
        logger.debug("GOT NEW TEXT MESSAGE1: " + msg);
        Notification n  = new Notification.Builder(this)
                .setContentTitle("New Message Received")
                .setContentText(msg)
                .setContentIntent(pIntent)
                .setAutoCancel(true)
                .addAction(0, "Ok", pIntent).build();

        NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        notificationManager.notify(0, n);
    } 
</code></pre>

<p>As per the logs, I am getting the message correctly - </p>

<pre><code>GOT NEW MESSAGE0: hello
GOT NEW MESSAGE1: hello
</code></pre>

<p>But still I am not getting any notification. Is there any problem in my code.</p>