Skip to content Skip to sidebar Skip to footer

Waiting For Gps Fix Dialog Box Throws Bad Token Exception - Android

I'm trying to show a dialog box that says waiting for GPS fix on a map. But it throws BadTokenException. Can some one please correct my code. I not necessarily need a dialog box. I

Solution 1:

The context you pass to the ProgressDialog must be an Activity, not an Application.

Change

dialog = ProgressDialog.show(getApplicationContext(), "Please wait...","Retrieving GPS data ...", true);

to:

dialog = ProgressDialog.show(this, "Please wait...","Retrieving GPS data ...", true);

Solution 2:

From the error it seems that you are using the wrong context here.

dialog = ProgressDialog.show(getApplicationContext(), "Please wait...","Retrieving GPS data ...", true);

So, try to use it like this

dialog = ProgressDialog.show(MapViewer.this, "Please wait...","Retrieving GPS data ...", true);

Post a Comment for "Waiting For Gps Fix Dialog Box Throws Bad Token Exception - Android"