I'm making a popup in Android using Toast, is there any way when shown to blur the window behind. I'd usually use:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
But in this case am not sure how to go about it... Any help would be great, thanks!
A Toast is designed to be unobtrusive and only appears for a short time so blurring the background would stop the user from continuing to use the phone. From the Android SDK:
When the view is shown to the user, appears as a floating view over the application. It will never receive focus. The user will probably be in the middle of typing something else. The idea is to be as unobtrusive as possible, while still showing the user the information you want them to see. Two examples are the volume control, and the brief message saying that your settings have been saved.
You would be better using a Dialog if you want to guarantee the user's attention, you should then be able to blur the background:
http://developer.android.com/guide/topics/ui/dialogs.html
Related
What i wanted to do, and didn't find any suitable solution, is :
create a scene in tasker (no problem on doing it :) )
display this scene on overlayed mode on other app (ex: waze,). Overlay is mandatory (as i know but i am maybe wrong) to let's the underlayed application work and refresh screen normally
allow interaction with button on the scene, just like we can do it if i choose the dialog mode for my scene. The problem with dialog mode is that the underlayed apps screen does not refresh.
In fact what i wanted to to is to display some button when i am running waze, to allow me to sens ETA Sms to my wife, or skip to the next track on my musics apps, or close waze quickly.....
As a resume i want to do what is
create floating windows like offered by apps like Overlays
but only using tasker
Best regards
Best
Please share some images of your requirements so that we can help you better but anyways I found a solution maybe it'll help you with some little customization.
According to my understanding, you need something like this:
You can download the whole project and customize it according to your requirements from Here
I am re-pharsing my question to avoid negative points. I am aware of web view, dialogs, popups, notifications. if you have some other ideas please let me know.
I am working on a very big android application, in which I have to add some popup kind of thing, which tells the user what we have updated for this version. Kind of like, what bugs are fixed or whats new things are added.
The window have to be populated once or twice and it have to have user interactions, like click on the link, or contact us, or click on the image to go to some page inside the app. Please let me know any good ideas.
You definitively should give a look to the AlertDialog class
http://developer.android.com/reference/android/app/AlertDialog.html
This is basically the class used to display a message and get the ok/cancel/anything answer from the user. But it's customizable and you can make more or less what you want according to which button is pressed by the user.
I would like to display a message to the user for some asynchronous event. For example for an alarm expiration. I would like to display a popup or dialog that is displayed over any activity is the foreground at the moment (and this can be some other application activity) leaving the current activity in the backgound.
Is there a way to do so in Android?
First off, you will be told that this is a bad thing to do, that it is against the Android way of doing things. Users do not like this. And that the Notification area is much better way to do this.
That said... there are ways to accomplish this...
A Toast will display no matter which activity is on the screen. So you could set up a background thread (or better a Service) that will display your information in a Toast. This might be good enough for you.
You may find it useful looking at some Toast source code here.
Also here is a nice page on how to create a custom Toast layout by replacing the default View with one of your own. (I have not done this, but it looks quite interesting):
Custom Toast Alert on androidexample.com
The alternative is much more difficult, and is to display a System Overlay window. Unfortunately you have to do quite a lot of work to get these set up properly.
Here are a few related questions that I used to get it working:
Creating a system overlay window (always on top)
System overlay android 4.0
How to create a system overlay in Android which allows interaction with the windows below it?
Each of these has links to many others - there are loads of System Overlay questions on here.
But things to remember:
In the old days, you could put a system overlay on top, and send
touches through to the activity below. This is no longer possible,
and so a lot of the answers are now out of date.
You may need to
play around with the flags in the provided examples to get exactly
the effect you are aiming for. Not all the examples use the same
flags, so there are some subtle differences in how each solution
works.
Then again, I also believe that the Notification area is a much better UI pattern to use, so I do recommend you try that first. It is easier to do, and most of us expect that type of behaviour rather than a pop-up.
The problem with a pop-up, is that it might interrupt a movie I'm watching. Or a game I'm playing.
Yes, i had created two dialog for income event for background and foreground
I'm wondering how to display the "hint circles" (I don't know what they're really called, and I couldn't find it anywhere) when opening an app for the first time. I've seen this in many stock android apps, but not in many third party apps. Is there even a way to do this?
Thanks!
Here is a picture of what i mean. (The blue circle with the OK, not the white one)
there is a library for that, check ShowcaseView
From what I have experienced with these, they seem to just be a form of a splash screen, or another image overlaying the actual app. Even if the stock apps don't handle it like that, couldn't you just have the app open up a new screen that contained a mostly transparent image except for where you want the ring or other hints. Then you can just at a button to that screen, so that after the user has read all of the hints, then they could close the screen.
I do not know how to totally do this, but since you said you couldn't find any documentation on it, I figured this could either give you a solution or point you in another direction to keep looking.
First of all, I know this has been asked before: Button in custom Android Toast?.
This is nearly an exact duplicate, but I think that it warrants a new question based on the fact that it's been used in apps, namely Gmail for ICS (it appears when you delete a message).
The linked question says that it's not possible to include a button in a Toast because Toasts cannot be focused. Is this wrong, outdated, or did Gmail find a way around it?
The Gmail undo bar is't a toast, here is how Google did it
http://code.google.com/p/romannurik-code/source/browse/misc/undobar/src/com/example/android/undobar/UndoBarController.java
I guess this answers your question.
What you're referring to is not a Toast but what Google has dubbed a Snackbar. See the Material Design guidelines.
You can find several implementations of this on GitHub. Some also go by the name of UndoBar
Currently, the most extensive, popular, and active one seems to be Snackbar by nispok, which I also happen to be using.
If you want a button in a toast, its better you quit that idea. But you can use dialogs in place of toast. Using dailogs, you will be able to display whatever you want (same function as a toast would do). Also in the dailog, you could set buttons.
Gmail on iOS does provide a toast and it is a much better solution than interrupting the user flow with a dialog.
![Toast style message in Gmail for iOS][1] [1]: http://i.stack.imgur.com/LWClq.jpg
If you use this option, make sure the toast is displayed long enough for the user to tap undo if needed. So 5 seconds as opposed to 2.5-3 seconds in a info-only toast.
The other example cited by CommonsWare is the inline feedback which is shown after a swipe gesture. This is not a toast- but it is also a great way to provide feedback that an action has been performed.
I have extended the UndoBar mentioned by #Hazem (link) and made it more generic so that it can be used for other actions also. You can have a look here.