In my app I am receiving notifications and I can able to see them in logs. But on some mobiles they are not being displayed. Ex : One plus A0001 (Android 5.1.1 API22).I have read other stackoverflow questions and ensured that all required methods are there.After some exploration I came to know that Cyanogenmod might be the reason for this.But in that case How other apps notifications are displayed.
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(this, MainActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);
Notification n = new Notification.Builder(this)
.setContentTitle("New mail from " + "test@gmail.com")
.setContentText("Subject")
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pIntent)
.setAutoCancel(true).build();
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(6578, n);
}
Above code working on all other mobiles.