diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index e91fcf0..8b7ccd3 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -18,6 +18,7 @@ Réalitée augmentée Liste des AOC de la commune : + Les services de géolocalisation (GPS ou réseau) semblent désactivés !\n\nVoulez-vous en activer un pour utiliser cette application ? diff --git a/res/values/strings.xml b/res/values/strings.xml index 86eb4cf..2b7b8f7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -18,5 +18,6 @@ Augmented reality List of the AOC\'s town : + Location services (GPS and network) seem to be disabled!\n\nDo you want to enable one of them to use this application ? diff --git a/src/com/franceaoc/app/ui/activity/DashboardActivity.java b/src/com/franceaoc/app/ui/activity/DashboardActivity.java index e79a654..3f088ea 100644 --- a/src/com/franceaoc/app/ui/activity/DashboardActivity.java +++ b/src/com/franceaoc/app/ui/activity/DashboardActivity.java @@ -15,7 +15,11 @@ package com.franceaoc.app.ui.activity; import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; import android.content.Intent; +import android.location.LocationManager; +import android.provider.Settings; import android.view.Menu; import android.view.MenuItem; @@ -104,4 +108,43 @@ private void startOptions() Intent intent = new Intent(Constants.ACTION_OPTIONS); startActivity(intent); } + + + @Override + protected void onResume() + { + super.onResume(); + final LocationManager manager = (LocationManager) getSystemService( LOCATION_SERVICE ); + if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER) && !manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) + { + buildAlertMessageNoLocation(); + } + } + + + private void buildAlertMessageNoLocation() + { + final AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage( R.string.message_activate_location ).setCancelable(false).setPositiveButton( getString( android.R.string.yes ), new DialogInterface.OnClickListener() + { + + @Override + public void onClick( final DialogInterface dialog, final int id) + { + startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); + } + }).setNegativeButton( getString( android.R.string.no ) , new DialogInterface.OnClickListener() + { + + @Override + public void onClick(final DialogInterface dialog, final int id) + { + dialog.cancel(); + finish(); + } + }); + final AlertDialog alert = builder.create(); + alert.show(); + } + }