DialogFragment not showing after adding Alert Window
Asked Answered
R

2

13

I have a function that when triggered, succesfully displays a DialogFragment with the following code

DialogFragment

DialogFragment dialog;
View dialogView;
Context activityContext;

...

dialog = new DialogFragment(){
   @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
      dialogView = getActivity().getLayoutInflater().inflate(R.layout.customView, null);
      ...
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      builder.setView(dialogView);
      return builder.create();
   }
};

dialog.show(activityContext.getSupportFragmentManager() , "MyDialog");

The problem is, after I add a System Alert window with the following code the DialogFragment no longer shows, BUT if I pass to another app, when my app minimizes I can see the DialogFragment while it's reducing it's size

System Alert Window

WindowManager mWindowManager;
WindowManager.LayoutParams params;

...

mWindowManager = (WindowManager)activityContext.getSystemService(Context.WINDOW_SERVICE);
params = new WindowManager.LayoutParams(
   WindowManager.LayoutParams.WRAP_CONTENT,
   WindowManager.LayoutParams.WRAP_CONTENT,
   WindowManager.LayoutParams.TYPE_PHONE,
   WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
   PixelFormat.TRANSLUCENT
}
params.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
addView(((LayoutInflater)activityContext.getSystemService("layout_inflater")).inflate(R.layout.floatingBotton, null));

So... Why can't I see my dialog at the top (as far as I understand, the dialog is displaying) Why it only happens when the System alert window is displayed

I've tried with other flags for the System Alert Window, but I have the same problem with the ones that I've tried

Rattoon answered 5/2, 2015 at 19:39 Comment(4)
are you adding it to the dialogfragment's window?Puce
is the dialog.show method is of your own ? show method of dialog is deprecated in API Level 13, you need to use fragment manager to show your dialog. Show the Dialog Fragment class for better understanding..Baucis
AFAIK the dialog z-index is determined in order of they are shown, for instance you display your dialog fragment after window manager inflating layout then your DialogFragment will show on top of other layouts. Precedence given to the last displayed on screen.Baucis
it may help you solve your issue:- [1]: #15976488Kagera
B
0
FragmentManager fmg1=this.getChildFragmentManager();
//or
FragmentManager fmg1=this.getFragmentManager();

dialog.show(fmg1 , "MyDialog");

Please try this it may Usefull

Babe answered 9/6, 2015 at 11:52 Comment(0)
Z
0

specify the view group ing inflate and set attach to root to true

http://developer.android.com/reference/android/view/LayoutInflater.html#inflate(int, android.view.ViewGroup, boolean)

addView(((LayoutInflater)activityContext.getSystemService("layout_inflater")).inflate(R.layout.floatingBotton, null));
Zoomorphism answered 15/6, 2015 at 14:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.