The essence of the problem: if there is a PIN-code on the device screen, an Android screen pattern, or something like that, then clicking on Push simply calls the MainActivity application. If there is no key, it opens the desired Activity .

My GCMListener code :

 @Override public void onMessageReceived(String from, Bundle data) { String id = data.getString("news_id"); String message = data.getString("message"); Random random = new Random(); Intent intent = new Intent(this, SpecificNewsActivity.class); intent.putExtra("newsId", id); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, random.nextInt(), intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher) .setContentTitle(getString(R.string.app_name)) .setContentText(message) .setAutoCancel(true) .setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(random.nextInt(), notificationBuilder.build()); } 

What could be a mistake?

Extras: It turned out that such a problem is only on Chinese phones (Meizu, Xiaomi for example).

  • And if the application is stopped (through the application manager, for example) and then opened through the notification, does it work out normally? - KoVadim
  • @KoVadim It is necessary to protest, I do not remember whether I tried it or not. - Pavel Borisov
  • @KoVadim If unload, it works. And the strange thing is, on the nexus 4 it works fine with the pin code of the screen, but not with the maoi xiaomi. Do not know what it could be? - Pavel Borisov
  • I would print the contents of the intend first and look carefully. It is possible that the third-party launcher spoils everything. - KoVadim
  • @KoVadim Checked, the content is working fine and the item that came immediately marked as read. - Pavel Borisov

1 answer 1

If anyone else will face this. The question was solved simply - the requests to the server were transferred from the activation in which there was a fragment to the fragment itself. Without this, on xyomi and maze, the activation dropped at the stage of the fragment transaction into the frame layout.