I have an activity that is using the Theme.Dialog style such that it is a floating window over another activity. However, when I click outside the dialog window (on the background activity), the button on activity start behaviour again. How can I stop this behaviour?
Use DialogFragment instead of activity
Related
I'm trying to display an activity with a button that covers a portion of the screen similar to a dialog.
This was almost working as I wanted it by using #android:style/android:Theme.Holo.Panel. It wasn't quite what I wanted however as I want the background to be dimmed with the activity is displayed. So I switched to this style instead: #android:style/android:Theme.Holo.Dialog.NoActionBar.
Now this looks like I want it and the background is dimmed. BUT the problem with this is if the user touches anywhere on the screen apart from the dialog then the activity gets dismissed. This does't happen with the Panel theme, the user can only dismiss it by pressing on the button.
How can I prevent the activity from being dismissed on any touch event with the Theme.Holo.Dialog?
Have you tried this.setFinishOnTouchOutside(false); ?
This being your activity.
I am debugging some code where A service adds a system alert window on top of an activity as a result of a key event.
The window has input fields, for which the keyboard gets displayed which clears the fullscreen flags which the top activity had set when it was created.
This can only happen if the top activity wasn't sent to the background when the service added the system_alert_window on top of the activity.
Thus i wanted to confirm whether, an activity goes to background or onPause() when a system_alert_window is added on top of it, like would happen if an another activity starts on top of it.
I did more research as part of an ongoing bug to modify AOSP.
In the process, i learnt that
No opening an alert window on top of an activity shouldn't and doesn't send it to background or call onPause().
The activity window is no more in focus, when an alert window gets opened on top of it, but the activity view is still visible, ie. view.visibility =VISIBLE.
When the overlay window is exited, the activity window again gains focus.
I want to show transparent dialog-like activity when my app goes to background. But after it shows I can see the last running activity underlaying. Can I show only my transparent activity without finishing previous?
I found solution. I have been used System alert instead Activity.
My appliation do the following:
Start a alarm
after 10 second
open a Activity (ThemeDialog)
The output is as follows
I would like to do the following:
Just show the dialog without showing the main activity
But the current situation is that the main activity is opened when I open my dialog activity.
How to hide it (when the alarm timesup, i just want to display a dialog)? Just like the following screen shot:
http://www.whatsappen.nl/wp-content/uploads/2012/05/popup21.jpg
You just also finish activity and than open new activity. New Activity' s style to android:theme="#style/Theme.Translucent" in your manifest file. And than set a view maybe empty textview, open dialog.
you can acheive this by using custom dialog
.in this give background color to black it will hide back activity
or you can acheive this by launching activity as dialog
Start activity as dialog i used this
<activity android:theme="#android:style/Theme.Dialog" />
now when i startActivity(in) it displays like dialog.
instead of showing dialog in activity you can directly use dialog theme in manifest file for activity.and use that activity as a dialog box.
I have a popup which I implement with an activity, e.i the activity doesn't fill the whole screen, and looks like a popup.
How can I disable the caller activity? (The background activity).
I want the same functionality as if I used a classic popup:
popup.setOutsideTouchable(false);
Thanks in advance!
you can create an activity with
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen".
There add your view over the transparent activity like a popup.