views:

56

answers:

1

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.

A: 

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(...)
Pentium10
okay, sounds good.Where would I implement an onActivityResult()?
jwheels
On the context. Maybe you should create a private Activity class inside the broadcast and use that.
Pentium10
Pentium, I am trying to implement your solution, however, adding a startActivity() at the end of my onReceive() I created a new Activity called Floater which for now simply has an 'OK' button.Its entry in the manifest:<activity android:name="Floater"android:theme="@android:style/Theme.Dialog"android:label="Type now"></activity>Code at the end of my BroadCast Receivers onReceive(): //---display the floating activity Intent i = new Intent(context,Floater.class); context.startActivity(i);Seems to do nothing when a text is received.
jwheels
err. that doesn't look so good. How do i use those nifty code blocks?
jwheels
Check out this example: http://code.google.com/p/publicobject/source/browse/shush/src/com/publicobject/shush/OnRingerMuted.java The code blocks works in Question and Answers with Control + K
Pentium10
Thank you sir. Fixed.
jwheels