0
How can I make a custom alertDialog close after the user activates the gps? The dialog box tbm can not close while the gps condition is false, that is, while it is disabled alertDialog has to remain, but when active gps the dialog box still remains.
Follow my code:
LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE);
final boolean enabled = service.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (!enabled) {
LayoutInflater li = getLayoutInflater();
View view = li.inflate(R.layout.alert_dialog__custom, null);
final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
final AlertDialog alert = alertDialog.create();
alertDialog.setCancelable(false);
view.findViewById(R.id.btn_claro).setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
onStop();
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
}
});
view.findViewById(R.id.btn_depois).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
AlertSair();
}
});
alert.dismiss();
alertDialog.setView(view);
alertDialog.show();
} onResume();
Could you be a little clearer? Can’t apply my code. Still the same thing. The alert still continues even after activating. How do I close Alertdialog within this condition? I’m a beginner yet.. =(
– JhonyC Canedo
The top part that spoke I understood, but the bottom part could not apply in my code.
– JhonyC Canedo
Another question is also how can I always keep making the check whether the gps is activated or not? pq the user can enable and disable and the program does not do another check to know. some light? thanks in advance friend
– JhonyC Canedo