开发者

how to to pop up and ask for user input on android after receiving broadcast

开发者 https://www.devze.com 2023-01-07 13:08 出处:网络
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.

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 mes开发者_如何学Csage 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.


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

<activity android:name=".utils.TextEntryActivity"
        android:label="Type in the value" android:theme="@android:style/Theme.Dialog" />

For starting other activity from BroadcastReceiver you can use the passed Context of the onReceive event.

context.startActivityForResult(...)
0

精彩评论

暂无评论...
验证码 换一张
取 消