如何在android上收到广播后弹出并要求用户输入
嘿,我是 Android 开发新手,正在尝试制作我的第一个应用程序。
我试图实现的是我在 Handcent SMS 中看到的一个功能:弹出通知。
到目前为止,我的应用程序有一个广播接收器,它使用 Toast 来显示传入的 SMS 消息。
但是,我不想制作一个 Toast 通知,而是制作一个弹出窗口来显示消息,并为用户提供一个输入回复的空间和一个发送按钮。 (也是一个简单地确认消息而不回复的按钮)
我将如何实现这一点? 我可以制作自己的“浮动”活动并使用 startActivityForResult 吗? 由于广播接收器不应该做任何繁重的工作,因此是否必须从服务内部触发?
或者我可以使用NotificationManager之类的东西。
hey, im new to android development and trying to make my first application.
What im trying to implement is a feature i've seen in Handcent SMS: the popup notification.
So far, my application has a broadcast receiver that uses Toast to display an incoming SMS message.
However, instead of a Toast notification, I want to make a pop up window that shows the message and offers users a space to type a reply and a button to send. (also a button to simply acknowledge the message without replying)
how would I accomplish this?
can I make my own 'floating' activity and use startActivityForResult?
would that have to be fired from inside of a service since broadcast receivers arent supposed to do any heavy lifting?
or can i use NotificationManager or something.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要有一个活动(布局+事件等),并且为了“浮动”,您需要将其主题设置为对话框,这可以在您定义活动的清单文件中完成,
类似
于从 BroadcastReceiver 启动其他活动您可以使用
onReceive
事件传递的Context
。You need to have an activity (layout+events etc) and in order to be 'floating' you need to set it's theme to dialog, this can be done in the manifest file where you define your activity
Something like
For starting other activity from BroadcastReceiver you can use the passed
Context
of theonReceive
event.