I have an issue with my android dialog. I would like it to be displayed over any activity (probably a no-no as far as design guidelines but I have good reason). This works. And I'm %95 happy with it. The issue is there seems to be an activity background still displayed beneath my dialog. This is apparent if I don't call finish() on my activity on each intended close action. Which I've done so it's less problematic, however, the dialog closes a split second prior to the activity background being cleared so the user sees an ugly centimeter long box for a split second as it finishes.
[____]
Is there any way to combat this? I've tried all of the API dialog themes: No action bar, no title bar, transparent, etc etc to no avail. I also attempted to set the dialog color to full transparency as well.
I had the same problem and my solution was:
#Override
protected void onPause() {
this.finish();
super.onPause();
}
Related
I am using a dialog themed activity in android to show a popup from a application context. The dialog has a transparent theme, but the issue is that I want the underlying activity to have focus and not the popup though the popup must be visble. How do I achieve this in android?
I think you would have to use a Fragment and just make it look like a popup dialog.
You can not switch focus between activities. There's only one activity "on focus" at the time, and is the one that is being displayed at that point. The transparent background doesn't mean you can access the activity below.
If i don't get it wrong, you want to be able to interact with the activity's controls while having a "Dialog" on the screen. Any sort of Dialog class from Android will not help, since they take the focus away. Not really sure about PopupWindow, but i'm guessing will be the same thing as the documentation says "that appears on top of the current activity."
You are going to have to create a custom dialog using a RelativeLayout/FrameLayout within your activity.
I have read really a lot of posts about this topic, however nothing works for me (or doesn't have the effect I wish).
I have a an application, that after logging in starts a background Service (implementation of the Service class). This service syncs itself with a Server and if a new order comes, it creates a notification.
So far, everything works great, I have the notification and the Toast message. However, I would like to have a dialog, that notifies the user about the new order.
As I understood, you can start an activity from within the service, which displays the dialog. This works, but the activity starts on top of the current activity stack and displays the dialog. I have an activity with no view attached and it correctly displays the dialog, however, on a black background.
What I want is to display the dialog on the current activity, causing the actual background(the running activity) to fade and display the dialog.
Is this somehow possible?
We can show dialog from service only if it is a system alert dialog. So, set TYPE_SYSTEM_ALERT window layout parameter to Dialog as follows:
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
But, it needs SYSTEM_ALERT_WINDOW permission. So, don't forget to add this permissin in Manifest file.
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
Edit:
Better option to show dialog is to start activity as one of the below ways.
Start Activity with Dialog Theme (android:theme="#android:style/Theme.Dialog") -(or)
Start Translucent Activity and show Dialog in it.
Note: You should add Intent.FLAG_ACTIVITY_NEW_TASK to intent
I highly, highly, HIGHLY recommend that you DON'T do this (it goes against Android design and UI guidelines). Notifications are the preferred way to accomplish what you are doing (which it sounds as if you have already accomplished).
That being said, if you must do it, I would recommend just using a Dialog themed activity. That way you don't have to start up a separate dialog. Please see http://developer.android.com/guide/topics/ui/themes.html#ApplyATheme for how to do this.
you can start by learning on how to create an activity that looks like a dialog (no title bar, transparent background, "floating" effect, etc.)
and no, you can't just start a dialog without an activty
No, you can't hijack activity that is not "yours" and command it to show dialog.
Your approach of starting your own activity is the classic one.
You cannot show a dialog. But you can go the alernative way by inflating your customized view so that you can show a dialog on the screen whenver certain conditions are met.
If I open a progress dialog the current activity visually goes to background (it gets darker). I also want to use this visual feedback (style) if I am working on longer running background tasks but without using a progress dialog. Does anybody know how to do that?
I think if you are doing something time consuming then you should indicate this with an indeterminate dialog (the one with a spinning wheel) along with a message explaining what you are doing. Otherwise the user will be confused about what is going on.
If you absolutely refuse to show the dialog, you could re-create the dark background by having a transparent view that covers the entire activity and then setting its background colour to a translucent black to make what is behind it appear darker.
I’ve created a search activity in my app, in the standard Android way, without custom suggestions. When a user starts typing text or presses the search button, they get a search dialog with search box, something like figure 1 from here:
http://developer.android.com/guide/topics/search/search-dialog.html
You’ll notice in the background is the previous activity, the words “abide”, etc.
My problem is that the previous activity is shown clear as day behind the search dialog, and its confusing for users, because users think all that is still active, and they try to press on it, but it just cancels the search dialog. And it distracts the user from the search task (are those search results, they may wonder?).
Question: how to blur (make out of focus) or darken the previous activity?
I actually see this in some app’s search screens.
I found a simple way to blur the background of the search dialog:
Basically it's just adding a (half) transparent view over the ListView (or what is under the dialog) and hide it by default. If the search dialog appears (calling onSearchRequested()) it is set to visible, if it disappears it's set back to gone (invisible).
Check out the details at my blog: http://mavistechchannel.wordpress.com/2011/08/13/blur-background-android-search-dialog/
Assuming you got dialog from a Dialog.Builder, use the following:
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
The Title is almost the entire question but i'll complement it with some things :
-(1) I have a AsyncTask for get some data from Internet
-(2) I have a AsyncTask for display a Progress Dialog
Before call (1) , I execute (2) dialog.show() and when task (2) ends I call dialog.dimiss(). All is doing right , but while the Progress Bar is showing the Menu Button stay unresponsiveness, ie , nothing happens...
I would like to know if it is the default behavior or i missing something ?
I'm looking for it and did found anything that clear me about it..
Aprecciate any advice
You mean to say that while the dialog is showing, pressing the hard menu button does not bring up the menu. Did I get it right?
If so, then I see the same behavior as you. But according to this:
For example, when a dialog is open,
the Menu key reveals the options menu
defined for the Activity and the
volume keys modify the audio stream
used by the Activity.
So I would expect that the menu button should still work even if the dialog is showing, but based on my experience, it does not.
After the dialog is dismissed, the menu button should work again.
onCreateOptionsMenu is meant to prepare the dialog. Once it is shown and in use it is no longer being prepared and thus use of the dialog is then handled in onOptionsItemSelected.