Skip to content Skip to sidebar Skip to footer

How To Open Application While Clicking Notification?

I have implemented media notification and lock screen notification in my music player. While clicking lock screen notification, how to ask the password to the user and how to open

Solution 1:

What do you mean by ask for password? just open an activity that asks for password.

As for open an activity use Nirali solution in: Open application after clicking on Notification

NotificationManagernotificationManager= (NotificationManager) context
        .getSystemService(Context.NOTIFICATION_SERVICE);
Notificationnotification=newNotification(icon, message, when);

IntentnotificationIntent=newIntent(context, HomeActivity.class);

notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
        | Intent.FLAG_ACTIVITY_SINGLE_TOP);

PendingIntentintent= PendingIntent.getActivity(context, 0,
        notificationIntent, 0);

notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, notification);

Solution 2:

For "open with" you should define intent-filter in your manifest. Look at this register as music player and https://developer.android.com/guide/components/intents-filters.html

Post a Comment for "How To Open Application While Clicking Notification?"