Interacting with background view when dialog is open? - android

I have an Activity, and inside that activity, i have several dialogs popup at unknown times. I would like the user to still be able to interact with the current activity (Press Buttons etc) whilst the dialog is being displayed. Is this possible or would there be an alternative solution to this? I have setup my dialog like so, to prevent it from closing on outside touch:
achievDialog = new Dialog(this);
achievDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
achievDialog.setContentView(R.layout.achiev_get);
achievDialog.setCanceledOnTouchOutside(false);

Related

Android standalone Alert Dialog

The normal way to create an alert dialog is to attach it to the current activity, like in How do I display an alert dialog on Android?
However, what I want to achieve is to create an alert dialog that is not attached to a particular activity. So that when the activity is destroyed (e.g. using finishAndRemoveTask), my dialog is still here.
Is there a way to achieve that? Also, I would like the area outside of the alert dialog to be unclickable, i.e. the user must click on the ok button of the dialog in order to navigate to other activities.

Start Activity from Soft Keyboard WITHOUT hiding the soft keyboard

I know this should not be a big challenge but it really drives me insane.
I am developing a simple soft keyboard input method and basically I have added a button to my softkeyboard, by pressing which, a dialog should pop up to prompt user to do some choices.
By far everything is ok about creating and opening the dialog. Since normally a dialog is created and displayed from outside an activity, so a flick solution could be to create a transparent activity which embedded the dialog in it. By doing so, I could easily start a dialog when user click the button on my softkeyboard.
But one tricky problem is: every time user click the button and the dialog (actually a dialog in a transparent activity) displays, it will always make my softkeyboard hide. I just need to start the dialog without any changes to the status of my softkeyboard -- I want my softkeyboard keeps showing when the dialog starts.
Here is a snapshot of Google Keyboard, it has the similar button which display a dialog and the dialog did not hide the keyboard, this is exactly what I want. So please anyone suggest me how to achieve this. Thanks so much.
THey aren't launching an Activity. They're launching a dialog. Which is tricky from an input method because its a service (you have to specify the dialog's window token to make it show) but doable.

Dialog with outside touchable

In an android application, I want to display a Dialog on screen and in the same time to allow user to click on the application's UI when the the Dialog is open
can this be done?
if no, what can I use instead of Dialog?
I don't think you can do this with Dialog. But you can do it with PopupWindow using PopupWindow.setOutsideTouchable(true);.
Showing up a dialog over your Activity, will make your Activity go into onPause() so you won't be able to actually handle things inside that activity anymore until the dialog is dismissed.
If you want to have some view, overlay your original activities view you'll be looking for into the direction of FrameViews, which can overlap other Views.

Opening Options Menu with Dialog Open

This seems like a pretty simple question, but I'm not sure if it's even possible. Is it possible to allow the MENU button to still bring up the option's menu when a dialog is showing on top? I want to do this because I want to give the user some more options while a dialog is opened.
I don't think that is possible.
Although the docs say that you should be able to do this.
A dialog is always created and displayed as a part of an Activity. You should normally create dialogs from within your Activity's onCreateDialog(int) callback method. When you use this callback, the Android system automatically manages the state of each dialog and hooks them to the Activity, effectively making it the "owner" of each dialog. As such, each dialog inherits certain properties from the Activity. 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.
http://developer.android.com/guide/topics/ui/dialogs.html

Android: Dismissing a dialog before displaying another

My application displays alert dialogs in some cases. Also, it is possible for a user to launch my application using the VIEW/SEND intent. The scenario I am considering is, the dialog is visible, the user presses 'Home' & selects my application to View/Share a file.
I would want to dismiss the dialog before beginning with the view/share operation. Although I can maintain which dialog is visible and hide it before the operation begins, I was wondering if there is a conventional/recommended way or API, something like activity.dismissAnyVisibleDialog() that can come in handy.
Thanks a lot,
Akshay
I finally myself maintained which dialog is visible & dismissed it before displaying the next one.
-Akshay
Just close the dialog in the onPause() method (override in your activity).
This way it will be dismissed when the activity is no longer visible i.e if you switch to the home screen.

Categories

Resources