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.
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 have one activity that keeps refreshing the elements on it based on the responses from our server, and i created another activity that overlays the 1st activity with some information i need to collect from the user if he wants, but when i pop up this 2nd activity which is transparent and shows what is in the background, the objects that were getting refreshed stopped moving because the activity went to pause mode.
Still i can see the content on the activity that is behind but nothing is moving anymore.
How can i get my 2nd activity working with the transparency and still be able to see the content of the background activity running?
You don't. An activity is paused whenever it is no longer the foreground activity- whenever any activity is launched on top of it. The transparency doesn't matter. If you don't want to be paused, don't make the new functionality an activity- make it a dialog, fragment, or an overlay of some sort.
You cannot. Android only allows one active activity at a time. So once an activity is in foreground, another activity will be placed in background and triggers onPause method. To make a transparent activity, you can make it as a dialog 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.
I am uploading/downloading some data in my application using AsyncTask. What I want is that, when the AsyncTask is running, the whole screen should get dimmed/disabled and a ProgressBar would be shown in the middle of the screen as long as the task is running.
Something like this
Any ideas / suggestions are most welcome.
Really need to implement it in my application!
the default "Dialog" theme does just that. You can do this
launch a new activity with the Dialog theme
the xml of that activity must have no background image/colour
show your dialog in the new activity
finish the activity, when the dialog is dismissed acc to your program logic
in the picture the dialogue is a Dialogue Activity. You can search on Goolge how to implement dialogue 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.