• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps custom dialog from an activity shows a window from another

So I'm displaying an AlertDialog (1), but with it appears a little window that should not be there (2).
2h2nuiv.jpg

This is the xml code for the Activity I'm displaying it from that should avoid displaying anything outside the activity.
Code:
      <activity android:name="Alarm"
                  android:theme="@android:style/Theme.Dialog"
                  android:launchMode="singleInstance" 
                  android:excludeFromRecents="true"
                  android:taskAffinity="">
        </activity>
The window also appears when I do something like this:
Code:
        Dialog dialog = new Dialog(this );
        dialog.setContentView(R.layout.myAlarm);
        dialog.setTitle("Custom Dialog");
        dialog.show();
But it never appears when I just call
Code:
setContentView(R.layout.myAlarm);
 
Why not define the dialog layout xml separately, and define the activity layout as having a transparent BG? (0x00000000)

Something to try anyways

hth
The Activity that is shown on the screen isn't the one the dialog is created in. The one on the screen is the MainActivity (the main UI), although it is missing all of its components (buttons etc). And those custom dialogs look fugly by default and I really don't want to put work into making a good one. There must be a way to stop the MainActivity window from displaying with my dialog..
 
Upvote 0
All I can think of is that you can have
excludeFromRecents in there on the main activity. But that could cause other problems, not really a solution I think.

Question though, how do you start the alarm activity? I think this might be an important peice to the puzzle. The activity with the dialog should be receiving an intent to launch it, or be launched from a Service or Broadcast Receiver.

However it might just not be possible -- why do you want such a dialog anyways?

You probably could use a sytem alerts but that permission really isnt meant for apps.
 
Upvote 0
All I can think of is that you can have
excludeFromRecents in there on the main activity. But that could cause other problems, not really a solution I think.

Question though, how do you start the alarm activity? I think this might be an important peice to the puzzle. The activity with the dialog should be receiving an intent to launch it, or be launched from a Service or Broadcast Receiver.

However it might just not be possible -- why do you want such a dialog anyways?

You probably could use a sytem alerts but that permission really isnt meant for apps.
I have a broadcastreceiver that onReceive creates a new Intent, adds some info to it and sets the (Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION) flags. Then I start it with context.startActivity(intent);
After some analysis and tests it appears what I'm looking for is a way to show a dialog without displaying the Activity it belongs to (and the MainActivity window displayed is still the activity I launch the dialog from, so my previous post is a bit incorrect). Transparency stuff is probably one option, but I'm hoping there are better ones out there.
As for changing the affinity, launchMode and allowReparenting - that unfortunately had no effect.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones