Regunath Siva
Regunath Siva

Reputation: 23

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 the application.

As well as for media notification while clicking I have opened the application. But how to close the notification bar or how to hide the whole notification bar Media Notification image

and how to show the suggestion of my application in "open with " while clicking the music file in any file directory.

Upvotes: 1

Views: 2332

Answers (2)

kara4k
kara4k

Reputation: 407

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

Upvotes: 0

fbwnd
fbwnd

Reputation: 705

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

 NotificationManager notificationManager = (NotificationManager) context
        .getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);

Intent notificationIntent = new Intent(context, HomeActivity.class);

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

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

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

Upvotes: 2

Related Questions