how to show custom dialog box when android application receives notification - android

popup message feature like whats app, caller id like the true caller, I am trying to make the same thing.
I tried using a broadcast receiver but I do not know how to show the dialog box when a broadcast receives a notification.
a pop-up message like WhatsApp shows when a notification arrives on a phone.

Set mainactivity as a launcher screen. In the mainactivity before setContentView method calling check if the intent has extra parameters as per your requirement. If yes, then finish the current activity and start DialogActivity.

Related

How show Dialog when app minimized and above another app if this app opened?

I have some Dialog. It shows when my app receipt message and I state in my Activity. I want show this Dialog if app minimized and not show Activity. (It is implemented in WatsApp). If pened somp app on phone, I want show dialog above this app.(It is implemented in WhatsApp too)
It executed when I receipt message and app is opened:
m_orderOfferForm = new NewOrderForm(BaseActivity.Instance, offerOrder);
m_orderOfferForm.show();
You can achieve this by background service continuously running for you and get the event of receiving or what you want to do. Then create intent for NEW ACTIVITY and in that intent create Dialog.!!!
Njoy. :)
This can be achieved using an activity as dialog. Run service in the background and on event trigger call activity from service.
Design of your activity layout should be like this
<Framelayout>
<Linearlayout
margin:20dp
background:translucent image(check for menu.popup.9.png)
layout_gravity:center>
<Content>
</Linearlayout>
</Framelayout>

In build notification bar in android

Any one can tell me how could i get inbuild notification listner in android. What all i want is if user put password on screen and if then some notification arrives. and if user click on notification, I want password field should be reset.
See http://developer.android.com/guide/topics/ui/notifiers/notifications.html#CreateNotification to create a local notification.
In the intent you use for the notification add an extra bit of data that you define (e.g. "ClearPassword" as a boolean of true).
In your activity, check for extras and your specific extra and if it is set then you can clear the field.
Why don't you just clear the password field in the onPause method of the activity? If the user clicks on the notification, the pending intent will launch a new activity (most in the cases from another application). When your activity is no longer the foreground activity, its onPause method will be called.

Android Notification Handling Suggestions

So I have a basic notification application. Here's the current configuration details:
GCMIntentService
NotificationActivity
:
---->ViewMessageActivity
:
---->ViewUserDetailsActivity
GCMIntentService is configured to do the following: Upon receiving a notification, a pending intent with PendingIntent.FLAG_ONE_SHOT is created and the intent adds the Intent.FLAG_ACTIVITY_NEW_TASK flag.
Currently, I have my NotificationActivity defined in my manifest as android:launchMode="singleInstance". If I set it to android:launchMode="singleTop", when the user clicks the notification a few things can happen depending on Android Version (or so my two devices show)
In Android < 2.3, If I'm in another activity (say ViewMessageActivity) and I press the notification from the shade, nothing happens (I don't receive anything from onNewIntent)
In Android 4.2 (Not sure about other versions), If I'm in another activity (say ViewMessageActivity) and I press the notification from the shade, nothing happens (I don't receive anything from onNewIntent) AND the notification disappears from the shade
If I'm in NotificationActivity everything works great regardless of version
So this led me to set it to singleInstance instead of singleTop. Now when the user presses the notification and the user is in a different activity (say ViewMessageActivity), the notifications intent is handled appropriately HOWEVER, my NotificationActivity tries to create a new instance of ViewMessageActivity for the message clicked in the notification shade and it does not create a new activity. Instead, shows my already opened instance. I've tried adding flags such as Intent.FLAG_ACTIVITY_NEW_TASK but neither my onCreate or onNewIntent methods are called in my ViewMessageActivity.
Ideally, this is what I would like to happen: When the user has navigated to another activity (say ViewMessageActivity) from the main activity (NotificationActivity) and the user presses a notification from the notification shade, I would like the NotificationActivity to be flagged to update its ListView view onNewIntent which will create another ViewMessageActivity instance. Note: I have no launchMode option set for any other activity.
Any suggestions?
Vince

Android Services, Activities and Handlers?

Im developping an Android Service in Android that needs to pop-up a new dialog box for confirmation.
I can popup a new activity using Intent and Context
Intent myIntent = new Intent(context, ConfirmationActivity.class);
But then I need to handle the option selected in the dialog box (OK or Cancel).
Any suggestion?
Note: Not developing for smartphones.
Update: I need to return the result to the place I call the Dialog.
A service should not pop up anything at all. Imagine the user is in the middle of a phone call when your dialog pops up.
If you need a confirmation from the user the best thing you can do is to use the NotificationManager and use a PendingIntent to launch an Activity. The Activity can still have a dialog style if you like.
Control flows back from the Activity to your Service then, so when the user presses ok or cancel you would either call a bound interface or use SharedPreferences to tell the service about the user's choice.

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

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.
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(...)

Categories

Resources