Hello, I need to realize the discovery of activity with a certain fragment.

How to implement it?

Of course when it is not working:

Intent intent = new Intent(this,ExamFragment.class); PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,0); 

But this code works, it starts the activity and the old fragment (which was last opened): `

  Intent intent = new Intent(this,Activity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,0); 

How to open the activity with the required fragment when clicking on the notification?

    1 answer 1

    It is impossible to display a fragment without activation.

    You need to start activating so that she knows that she needs to display a strictly defined fragment.

    To do this, put something in the activation launch network, pull it out in the activation tool and display the required fragment depending on it.

    • Intent intent = new Intent (this, ActivityFragments.class); intent.putExtra ("ExamFragment", "ExamFragment"); PendingIntent pendingIntent = PendingIntent.getActivity (this, 0, intent, 0); Will it be an intent to active? - Martinez Toni
    • @MartinezToni, yes. After that, either onCreate will be called up or onNewIntent - Yuriy SPb ♦
    • But when I get it in activity, value = null, why? Intent intent = getIntent (); String value = inente.getStringExtra ("ExamFragment"); - Martinez Toni
    • @MartinezToni, in what method do you do this? OnNewIntent should work - Yuriy SPb ♦