I am trying to do AlertDialogthat which is displayed when Fragmentdisplayed with the help setUserVisibleHint(boolean)that tells the user to turn on their GPS settings. I am using this code:
new AlertDialog.Builder(getActivity())
.setTitle(R.string.dialogLocationDisabledTitle)
.setMessage(R.string.dialogLocationDisabledMsg)
.setCancelable(true)
.setPositiveButton(R.string.gpssettings, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
mRecheckLocationOnResume = true;
}
})
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.create()
.show();
However, when you enter the application with GPS turned off and go to the screen, no button is displayed. When you enter the application, turn off the GPS, then go to the screen, it works fine. Can anyone guess why?
EDIT: as suggested by @ pax2K, I include the logcat snippet. I added the entries to the code above:
03-19 16:05:40.062: D/LocateServiceFragment(11193): Starting AlertDialog build
03-19 16:05:40.062: D/LocateServiceFragment(11193): Adding positive button
03-19 16:05:40.072: D/LocateServiceFragment(11193): Adding negative button
03-19 16:05:40.072: D/LocateServiceFragment(11193): Building AlertDialog
03-19 16:05:40.072: D/LocateServiceFragment(11193): Showing AlertDialog
03-19 16:05:40.182: D/LocateServiceFragment(11193): AlertDialog shown
03-19 16:05:40.803: I/Adreno200-EGLSUB(11193): <ConfigWindowMatch:2089>: Format RGBX_8888.
03-19 16:05:40.903: I/Adreno200-EGLSUB(11193): <ConfigWindowMatch:2078>: Format RGBA_8888.
03-19 16:05:41.123: D/dalvikvm(11193): GC_FOR_ALLOC freed 1560K, 19% free 17223K/21219K, paused 48ms
03-19 16:05:41.363: D/OpenGLRenderer(11193): has fontRender patch
03-19 16:05:42.084: D/memalloc(11193): ashmem: Mapped buffer base:0x5576b000 size:737280 fd:166
03-19 16:05:45.668: D/memalloc(11193): /dev/pmem: Unmapping buffer base:0x56ff8000 size:16613376 offset:15998976
03-19 16:05:45.668: D/memalloc(11193): /dev/pmem: Unmapping buffer base:0x53882000 size:614400 offset:0
03-19 16:05:45.668: D/memalloc(11193): /dev/pmem: Unmapping buffer base:0x57fd0000 size:1966080 offset:1351680
03-19 16:05:45.958: D/memalloc(11193): /dev/pmem: Unmapping buffer base:0x5857d000 size:4239360 offset:3502080
03-19 16:05:45.958: D/memalloc(11193): /dev/pmem: Unmapping buffer base:0x55e8a000 size:1351680 offset:614400
03-19 16:05:46.178: D/OpenGLRenderer(11193): Flushing caches (mode 1)
Either side is debugging statements from completely different parts of the code. I am not much wiser.
source
share