GPS 서비스가 사용 중지 된 경우 사용자에게 표시 할 대화 상자를 만듭니다. 그러나 무슨 일이 일어나고 있는데, 대화를 강제로하기 위해 서비스를 수동으로 비활성화했지만 앱이 시작되고 아무 일도 일어나지 않습니다.대화 상자가 표시되지 않습니다.
아래 코드는 대화 상자를 어떻게 만들려고했는지 보여줍니다. 실수가 있으면 알려주세요.
JavaCode : 당신은 대화 상자 표시 함수를 호출 할 필요가
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gpstest00);
locMgr = (LocationManager) getSystemService(LOCATION_SERVICE);
gpsEnable = locMgr.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (!gpsEnable) {
showGPSDialogueBox();
}
locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1, 1, this.locationListener);
}
/*if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
}*/
private void showGPSDialogueBox() {
AlertDialog.Builder alertDialogue = new AlertDialog.Builder(this);
alertDialogue.setTitle("GPS Settings");
alertDialogue.setMessage("GPS is deactivated. Do you want to switch " + to settings menu to activate it?");
alertDialogue.setPositiveButton("Settings",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
}
});
alertDialogue.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.cancel();
}
});
}// Enf of showDialogueBox function.