Showing posts with label AlertDialog. Show all posts
Showing posts with label AlertDialog. Show all posts

Thursday, December 16, 2010

Window fluctuation in case of AlertDialog

Hi Guys,
Today I was facing following problem
Problem:
In Gallery,if you view any image and in that if you select Menu-> Details.
At the time of display image it shows annunciator bar for a moment and just disappear. I dont want this. After analyzing this I found that this is not visible when the items in the dialog is limited to 2-3 items. So suggest me the solution. It is in the Google Froyo code.
So here is the solution for it
Solution:
 AlertDialog alert = builder.create();
Window dwindow = alert.getWindow(); 

dwindow.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,   WindowManager.LayoutParams.FLAG_FULLSCREEN);
alert.show();
Hope this will be useful for you.

Thursday, September 2, 2010

android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

Hi guys,
if you are facing this problem then it is problem with your context which you are passing in the AlertDialog, so make sure you are passing the Context which is initialized by
Context context = this;

And some times in case of Service, you can face this problem while you are using the correct Context. In that case use the following code before show() method.

AlertDialog ad;
// code for creating. .create();
ad.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
ad.show();

It will work.