Android - SMS Popup, wont open over itself - android

I have made an app that opens a popup, everything is working fine getting the SMS content, sender name and picture.
When a SMS is received it opens a popup shows all the details. But if the popup is already open it wont open another popup showing the content of the second SMS.
The thing that bothers me alot is that, I have PreferenceActivity for this app. When this activity is open then the app is able to open multiple popups, else it doesnt.
I would like to ask
1. How can I make my app to open multiple popups?
2. Why is it when PreferenceActivity is open, the app can make multiple popups
Some details:
For case 1, log is NOT giving me any sort of warning or error.
I have tried to use FLAG_ACTIVITY_NEW_TASK FLAG_ACTIVITY_NO_HISTORY FLAG_ACTIVITY_MULTIPLE_TASK and android:launchMode= "standard"
I have this AlertDialog in an activity, starting this activity from a broadcastreveiver
Thank you.

You are only allowed one popup window at a time and in this case you can treat Dialog like a Popup Window. I'm skeptical that you are able to see more than one popup window in your Preference Activity, but you may be seeing something that looks like it but isn't really more than one. This can be easily checked by using the hierarchy viewer to see what is actually layered.
If you want to have something like layered messages, like in a carousel, card edges, or use some other visual indication you would have use/build a custom view.

Related

How to add pop up option screen at start of app? Android studio

I'm looking to have a window pop up at the very start of my android app with two options on it.
I have two functional buttons already in my app and I'd like the user to pick one of the two buttons before they get in to the app.
Lets say the screen pops up at launch and I'd like it to say "Please choose either 'button1' or 'button2'"
I've found a few solutions but none that I can actually get working...think that might be might novice status though.
Thanks for any help.
You should create a splash screen (many tutorials can be found on this, here is an example). After having this activity, you can create a Dialog with 2 buttons (example here).
You can set a positive and negative button on the dialog to do this, and also use a callback for the click behavior (example here).

Get Android AlertDialog to appear on top of all activities at all times

Have been searching the web and stack overflow for this - I found a potential answer but it was not well explained enough for me as I am new to android.
I am working on an android app that displays alert dialogs at key times. I am currently having the app add the dialog to the current activity to make sure it appears.
However, sometimes the dialog can appear just as the user tapped a button to a new activity, causing the new dialog to be appearing on the previous activity and not seen unless the user hits back.
Another case is occasionally two dialogs will be appearing, and upon accepting the top-most the app brings the user to a new activity - leaving the second dialog on the previous activity and again unseen without hitting back.
The closest I could find was here: Keep dialog/activity always on the top
The above question was not fully explained in the answer. I tried following the advice by adding a new relative layout to each of my existing layouts with the ID "alert_layout" and I already had a BaseActivity all my activities extend from. When I need to show an alert I add it to the current activity's "alert_layout"'s context but it is yielding the same result. I am not sure how to add a layout that is never changed between activities - but even then, the AlertDialog is looking for a context to be added/shown to, not a layout, so I'm confused as to how to accomplish this.
I am new to Android development so I apologize if I'm missing the obvious, but I'm hoping there is an easy way to make sure AlertDialog is always on top of all activities and remains there across activity changes.
Thank you in advance for any assistance.
It's not going to work using Dialogs. You have to draw a View above the rest of your app's UI.
Android offers this possibility by drawing windows on top of all other applications. You need to have the SYSTEM_ALERT_WINDOW permission. Additional details in this question: What APIs in Android is Facebook using to create Chat Heads?

How does WhatsApp pop-up notification work?

I am trying to mimic the pop-up notification of WhatsApp.
(If you have not seen it, it might be a bit hard for you to understand this.)
Below is an image to give a clearer perspective.
Some suggested that this might be done using an oridnary activity which has the Theme.Holo.Light.Dialog.Alert theme. However, when I implemented that I got half of the activity full with the views (and the other half) which is supposed to be empty like a dialog, showing a white background. ie, I did not have the dialog feel.
Morever, when the device is in standby mode (power button pressed) and locked, whatsapp is able to bypass that and show the popup dialog (or activity, or whatever) above that.
Any ideas how to implement this ?
Oh god! After hours, I found the solution!
Refer link:http://developer.android.com/guide/topics/ui/dialogs.html#CustomLayout
It's extremely easy, you just need to set up the theme of the activity to #android:style/Theme.Holo.Dialog in manifest like:
<activity android:theme="#android:style/Theme.Holo.Dialog" >

Android Pop up window

I looked online and was not able to find a working example of the PopupWindow class. The code examples I found online either compile but do not work, or are using methods which have since been removed (such as Activity.getViewInflate()).
Is there a simple working example that displays a PopupWindow?
Any Activity can be a "popup window" it just has to show up on top of the previous activity and not take up all the screen real estate! :)
Here's an example of how this works...
How do I create a transparent Activity on Android?
Or are you just looking for an Alert that gets dismissed by being touched anywhere (rather than with an "OK" button?
May be AlertDialog can solve your problem you can full screen dialog window it just look like a window it is an alternative

Showing a Dialog and still delivering clicks to the background?

I want to show a small Custom Dialog on top of the current user activity, but have clicks to the area outside of my Dialog delivered to the background (which would be the launcher, or another activity). I tried to create a transparent base-activity and have the Dialog shown on top of it, but clicks are registered on the transparent activity and not on whatever is behind it...
I know that a Popup has a setOutsideTouchable-Method, but setting this to true just dismisses the popup, rather than delivering clicks to the background, to my knowledge...
Thanks for your help,
Nick
Based on this clarification comment you posted on another answer...
"I want the Dialog to be shown system-wide, no matter which App the user is using at the moment..."
I don't believe what you want to do is possible and I'm happy about that. :) If you were allowed to popup a little dialog box over anyone else's app and still have the user be able to interact with the current activity... then you could easily trick the user into thinking that the little popup belonged to the current app and not yours which is acting from the background.
Imagine all of the evil you could do with something like that. Prompting for the user to reenter their email password when they are in the Email.app.. and then just storing it for malicious purposes, etc.
It isn't possible.. and SHOULDN'T be possible. If you need to notify the user of something, then you should use the built-in notification system. That's why it is there! :)
You can use a PopupWindow "Dialog like" and show it for the user in top of your activity. The outside events will be delivered to the main Activity.
I can't see the deeper meaning of exploiting the using the given usability patterns of android by doing what you ask for?
It is recommended and meaningful to stick to common patterns so users don't have to adapt in basic apps. That is, unless you are working on a game:)
"I want the Dialog to be shown
system-wide, no matter which App the
user is using at the moment..."
That is what the notification system is for. It allows you to tell something to the user without interrupting him in whatever he was doing.
System wide dialog popup are evil and gladly not implemented in Android.
Use the notification system : http://developer.android.com/reference/android/app/Notification.html
Also if you are ok with only a dialog above YOUR app, then the simplest way to let the UI be still responsive while your dialog is up, is simply to recreate a dialog in a relativelayout view and display this instead of the common modal dialog.
You could switch places so that the popup is actually "behind" the initial screen, but then set the initial screen as transparent.
Edit: This would only be applicable within an application of course.

Categories

Resources