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

Яois
  • 3,838
  • 4
  • 28
  • 50
Maw Boc
  • 151
  • 8
  • are you adding it to the dialogfragment's window? – Elltz Jun 09 '15 at 03:45
  • 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.. – Murtaza Khursheed Hussain Jun 09 '15 at 06:32
  • 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. – Murtaza Khursheed Hussain Jun 09 '15 at 06:35
  • it may help you solve your issue:- [1]: http://stackoverflow.com/questions/15975988/what-apis-in-android-is-facebook-using-to-create-chat-heads/15980900#15980900 – pRaNaY Jul 08 '15 at 05:33

2 Answers2

0
FragmentManager fmg1=this.getChildFragmentManager();
//or
FragmentManager fmg1=this.getFragmentManager();

dialog.show(fmg1 , "MyDialog");

Please try this it may Usefull

wadali
  • 2,221
  • 1
  • 20
  • 38
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));
rahul.ramanujam
  • 5,608
  • 7
  • 34
  • 56