Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // string to store location providers available;
- private String _mProviders;
- // get location providers
- _mProviders = Settings.Secure.getString(getContentResolver(),
- Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
- // if gps is enabled and network location is disabled
- if (_mProviders.contains(_GPS) && !_mProviders.contains(_NETWORK)) {
- // build a new alert dialog to inform the user that they only have
- // GPS location services
- new AlertDialog.Builder(_mContext)
- //set the message to display to the user
- .setMessage(R.string.onlyGPS)
- // add the 'positive button' to the dialog and give it a
- // click listener
- .setPositiveButton(R.string.enableLocationServices,
- new DialogInterface.OnClickListener() {
- // setup what to do when clicked
- public void onClick(DialogInterface dialog,
- int id) {
- // start the settings menu on the correct
- // screen for the user
- startActivity(new Intent(
- Settings.ACTION_LOCATION_SOURCE_SETTINGS));
- }
- // add the 'negative button' to the dialog and
- // give it a click listener
- })
- .setNegativeButton(R.string.close,
- new DialogInterface.OnClickListener() {
- // setup what to do when clicked
- public void onClick(DialogInterface dialog,
- int id) {
- // remove the dialog
- dialog.cancel();
- }
- // finish creating the dialog and show to the
- // user
- }).create().show();
- // if gps is disabled and network location services are enabled
- } else if (!_mProviders.contains(_GPS)
- && _mProviders.contains(_NETWORK)) {
- // do nothing at present...
- // if gps is disabled and network location services are disabled
- } else if (!_mProviders.contains(_GPS)
- && !_mProviders.contains(_NETWORK)) {
- // build a new alert dialog to inform the user that they have no
- // location services enabled
- new AlertDialog.Builder(_mContext)
- //set the message to display to the user
- .setMessage(R.string.noLocationServices)
- // add the 'positive button' to the dialog and give it a
- // click listener
- .setPositiveButton(R.string.enableLocationServices,
- new DialogInterface.OnClickListener() {
- // setup what to do when clicked
- public void onClick(DialogInterface dialog,
- int id) {
- // start the settings menu on the correct
- // screen for the user
- startActivity(new Intent(
- Settings.ACTION_LOCATION_SOURCE_SETTINGS));
- }
- // add the 'negative button' to the dialog and
- // give it a click listener
- })
- .setNegativeButton(R.string.close,
- new DialogInterface.OnClickListener() {
- // setup what to do when clicked
- public void onClick(DialogInterface dialog,
- int id) {
- // remove the dialog
- dialog.cancel();
- }
- // finish creating the dialog and show to the
- // user
- }).create().show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement