I have written code to create a notification.
I would like the notification to directly open a fragment class called "StepsFragment".
However, whenever I click on the notification, nothing happens. What could be the issue here?
I have tried the following solutions on Stack Overflow:
Receive a notification issue and open a fragment
How to open current fragment from notification?
Open a dialog fragment from childfragment from Notification
They resulted in me encountering syntax errors and I'm unable to build my project as a result.
This is the code that I used to open up a fragment from the notification.
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        String input = intent.getStringExtra("inputExtra");
        Intent notificationIntent = new Intent(this, StepsFragment.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this,0,notificationIntent,0);
        Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
                .setContentTitle("Steps Tracker")
                .setContentText("Steps tracked : " + input )
                .setSmallIcon(R.drawable.steps)
                .setContentIntent(pendingIntent)
                .build();
        startForeground(1,notification);
        return START_NOT_STICKY;
    }
How do I open up the notification so that it will take me to StepsFragment instead of not doing anything when I tap on the notification?