单击通知时如何打开应用程序? [英] How to open application while clicking notification?

查看:53
本文介绍了单击通知时如何打开应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在音乐播放器中实现了媒体通知和锁定屏幕通知.单击锁定屏幕通知时,如何向用户询问密码以及如何打开应用程序.

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

以及如何在单击任何文件目录中的音乐文件时以打开方式"显示我的应用程序的建议.

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

推荐答案

询问密码是什么意思?只需打开一个要求输入密码的活动即可.

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

关于打开活动,请使用Nirali解决方案,网址为:在单击通知后打开应用程序

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);

这篇关于单击通知时如何打开应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆