2

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.

Dinesh Chitta
  • 670
  • 8
  • 23

1 Answers1

0

Check the notification permissions of your app. Which control by your phone. Maybe in Settings or an pre-installed app. Especially in China, many phones pre-installed an app called "权限管家" to control third-party app's permissions. Such as show notification in notification bar, connect to internet while running background or when screen is locked.

Oscar Zhang
  • 153
  • 2
  • 7