Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. LocationManager locationManager = (LocationManager) getActivity().getSystemService(LOCATION_SERVICE);
  2. if ( !locationManager.isProviderEnabled( LocationManager.GPS_PROVIDER ) ) {
  3. AlertNoGps();
  4. }
  5.  
  6.  
  7. private void AlertNoGps() {
  8. AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
  9. builder.setMessage("El sistema GPS esta desactivado, ¿Desea activarlo?")
  10. .setCancelable(false)
  11. .setPositiveButton("Si", new DialogInterface.OnClickListener() {
  12. public void onClick(@SuppressWarnings("unused") final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
  13. startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
  14. }
  15. })
  16. .setNegativeButton("No", new DialogInterface.OnClickListener() {
  17. public void onClick(final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
  18. dialog.cancel();
  19. }
  20. });
  21. alert = builder.create();
  22. alert.show();
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement