List of usage examples for android.provider Settings ACTION_LOCATION_SOURCE_SETTINGS
String ACTION_LOCATION_SOURCE_SETTINGS
To view the source code for android.provider Settings ACTION_LOCATION_SOURCE_SETTINGS.
Click Source Link
From source file:com.neighbor.ex.tong.ui.activity.MainActivity2Activity.java
private void chkGpsService() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getResources().getString(R.string.set_gps_title)); builder.setMessage(getResources().getString(R.string.set_gps_message)); builder.setPositiveButton(getResources().getString(R.string.info_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent); }//from w w w.j a v a 2 s .c o m }); Dialog alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); }
From source file:in.codehex.arrow.MainActivity.java
/** * display an alert to notify the user that GPS has to be enabled *//*w w w . ja va 2 s . c o m*/ private void showAlertGPS() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle("Enable GPS"); alertDialog.setMessage("GPS service is not enabled." + " Do you want to go to location settings?"); alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent); } }); alertDialog.show(); }
From source file:com.tenforwardconsulting.cordova.BackgroundGeolocationPlugin.java
public void showLocationSettings() { Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); cordova.getActivity().startActivity(settingsIntent); }
From source file:org.cowboycoders.cyclisimo.TrackListActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent;/*from w ww . j a v a 2 s . c o m*/ switch (item.getItemId()) { case R.id.track_list_search: return ApiAdapterFactory.getApiAdapter().handleSearchMenuSelection(this); case R.id.track_list_start_gps: if (!trackDataHub.isGpsProviderEnabled()) { intent = GoogleLocationUtils.isAvailable(TrackListActivity.this) ? new Intent(GoogleLocationUtils.ACTION_GOOGLE_LOCATION_SETTINGS) : new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); return true; } startGps = !startGps; Toast toast = Toast.makeText(this, startGps ? R.string.gps_starting : R.string.gps_stopping, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); handleStartGps(); updateMenuItems(recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT); return true; case R.id.track_list_import: AnalyticsUtils.sendPageViews(this, "/action/import"); intent = IntentUtils.newIntent(this, ImportActivity.class).putExtra(ImportActivity.EXTRA_IMPORT_ALL, true); startActivity(intent); return true; case R.id.track_list_save_all_gpx: startSaveActivity(TrackFileFormat.GPX); return true; case R.id.track_list_save_all_kml: startSaveActivity(TrackFileFormat.KML); return true; case R.id.track_list_save_all_csv: startSaveActivity(TrackFileFormat.CSV); return true; case R.id.track_list_save_all_tcx: startSaveActivity(TrackFileFormat.TCX); return true; case R.id.track_list_delete_all: new DeleteAllTrackDialogFragment().show(getSupportFragmentManager(), DeleteAllTrackDialogFragment.DELETE_ALL_TRACK_DIALOG_TAG); return true; case R.id.track_list_aggregated_statistics: intent = IntentUtils.newIntent(this, AggregatedStatsActivity.class); startActivity(intent); return true; case R.id.track_list_settings: intent = IntentUtils.newIntent(this, SettingsActivity.class); startActivity(intent); return true; case R.id.track_list_help: intent = IntentUtils.newIntent(this, HelpActivity.class); startActivity(intent); return true; default: return super.onOptionsItemSelected(item); } }
From source file:plugin.google.maps.CordovaGoogleMaps.java
private void _showLocationSettingsPage(final boolean enableHighAccuracy, final CallbackContext callbackContext) { //Ask the user to turn on the location services. AlertDialog.Builder builder = new AlertDialog.Builder(this.activity); builder.setTitle("Improve location accuracy"); builder.setMessage("To enhance your Maps experience:\n\n" + " - Enable Google apps location access\n\n" + " - Turn on GPS and mobile network location"); builder.setPositiveButton("Settings", new DialogInterface.OnClickListener() { @Override//ww w . j a v a 2 s.com public void onClick(DialogInterface dialog, int which) { //Keep the callback id Bundle bundle = new Bundle(); bundle.putInt("type", ACTIVITY_LOCATION_PAGE); bundle.putString("callbackId", callbackContext.getCallbackId()); bundle.putBoolean("enableHighAccuracy", enableHighAccuracy); int hashCode = bundle.hashCode(); bufferForLocationDialog.put("bundle_" + hashCode, bundle); CordovaGoogleMaps.this.sendNoResult(callbackContext); //Launch settings, allowing user to make a change cordova.setActivityResultCallback(CordovaGoogleMaps.this); Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); activity.startActivityForResult(intent, hashCode); } }); builder.setNegativeButton("Skip", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //No location service, no Activity dialog.dismiss(); JSONObject result = new JSONObject(); try { result.put("status", false); result.put("error_code", "service_denied"); result.put("error_message", "This app has been rejected to use Location Services."); } catch (JSONException e) { e.printStackTrace(); } callbackContext.error(result); } }); builder.create().show(); }
From source file:com.trailbehind.android.iburn.map.MapActivity.java
/** * Check gps provider.//from w ww .j a v a2s. c o m */ private void checkGPSProvider() { final LocationManager locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (!locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { mProgressBar.setVisibility(View.GONE); mMessageTextView.setText(R.string.error_gps_disabled); mMessageTextView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { mVibrator.vibrate(50); final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent); } catch (Exception e) { // we dont care } } }); UIUtils.showPanel(getBaseContext(), mMessagePanel, false); } else if (Globals.sCurrentGPSLocation == null) { mProgressBar.setVisibility(View.VISIBLE); mMessageTextView.setText(R.string.msg_locating); UIUtils.showPanel(getBaseContext(), mMessagePanel, false); } else { UIUtils.hidePanel(getBaseContext(), mMessagePanel, false); } }
From source file:com.mobantica.DriverItRide.activities.ActivityLogin.java
private void createLocationRequest() { mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(100);//from w ww . ja va 2 s . c o m mLocationRequest.setFastestInterval(50); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(mLocationRequest); try { PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi .checkLocationSettings(mGoogleApiClient, builder.build()); result.setResultCallback(new ResultCallback<LocationSettingsResult>() { @Override public void onResult(@NonNull LocationSettingsResult result) { final Status status = result.getStatus(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS: break; case LocationSettingsStatusCodes.RESOLUTION_REQUIRED: try { status.startResolutionForResult(ActivityLogin.this, 1); } catch (IntentSender.SendIntentException e) { } break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: AlertDialog.Builder builder = new AlertDialog.Builder(ActivityLogin.this); builder.setMessage(getResources().getString(R.string.please_on_location_settings)) .setPositiveButton(getResources().getText(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent viewIntent = new Intent( Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(viewIntent); } }); builder.create(); builder.show(); break; } } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:git.egatuts.nxtremotecontroller.fragment.OnlineControllerFragment.java
@Override public void onResume() { super.onResume(); if (!this.getWifiManager().isWifiEnabled()) { return;/*from w w w. j a va 2s . c om*/ } final OnlineControllerFragment self = this; this.token = this.getPreferencesEditor().getString("preference_server_token"); this.tracker = new GPSLocationTracker(this.getActivity()); if (token.equals("")) { if (!tracker.isGPSEnabled() && !tracker.isNetworkEnabled()) { this.getGlobalUtils() .createAlertDialog(R.string.geolocation_required_title, R.string.geolocation_required_message) .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ((ControllerActivity) self.getBaseActivity()).setTab(0); } }).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { self.startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); } }).setCancelable(false).show(); return; } this.progressDialog.show(); this.progressDialog.setText(R.string.getting_access_token); this.requester = this.getTokenRequester(); this.requester.setOnFinishListener(new TokenRequester.OnFinishListener() { @Override public void onFinish(String data) { try { JSONObject jsonObject = new JSONObject(data); if (jsonObject.has("state") && jsonObject.getInt("state") == -1) { self.requester.cancelRequest(new LoginException()); return; } final String token = jsonObject.getString("token"); if (token != null || token != "") { self.getActivity().runOnUiThread(new Runnable() { @Override public void run() { self.getBaseActivity().getPreferencesEditor() .saveString("preference_server_token", token); self.token = token; self.startSocketConnection(); } }); } else { self.requester.cancelRequest(new MalformedTokenException()); } } catch (JSONException e) { self.requester.cancelRequest(e); } } }); this.requester.setOnExceptionListener(new TokenRequester.OnExceptionListener() { @Override public void onError(Exception e) { //e.printStackTrace(); if (e instanceof ConnectException) { if (e.getLocalizedMessage().contains("ECONNREFUSED")) { self.getGlobalUtils().showToast(R.string.connection_error_refused, true); } else if (e.getLocalizedMessage().contains("EHOSTUNREACH")) { self.getGlobalUtils().showToast(R.string.connection_error_unreach, true); } } else if (e instanceof FileNotFoundException) { self.getGlobalUtils().showToast(R.string.connection_error_token_not_found, true); } else if (e instanceof MalformedURLException) { self.getGlobalUtils().showToast(R.string.connection_error_malformed, true); } else if (e instanceof MalformedTokenException) { self.getGlobalUtils().showToast(R.string.connection_error_token_malformed, true); } else if (e instanceof LoginException) { self.getGlobalUtils().showToast(R.string.connection_error_login, true); } } }); this.tracker = this.getLocationRequester(this.requester); this.tracker.startLocationService(); return; } this.startSocketConnection(); }
From source file:com.todoroo.astrid.taskrabbit.TaskRabbitActivity.java
@SuppressWarnings("nls") private void buildAlertMessageNoGps() { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(getString(R.string.tr_alert_gps_title)).setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), REQUEST_CODE_ENABLE_GPS); showingNoGPSAlertMessage = false; }/*from ww w . j a v a2 s .c om*/ }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { dialog.cancel(); showingNoGPSAlertMessage = false; showIntroDialog(); } }); final AlertDialog alert = builder.create(); alert.show(); }
From source file:org.mixare.MixViewActivity.java
public void setErrorDialog(int error) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setCancelable(false);/*from w w w . j av a 2s . c o m*/ switch (error) { case NO_NETWORK_ERROR: builder.setMessage(getString(R.string.connection_error_dialog)); break; case GPS_ERROR: builder.setMessage(getString(R.string.gps_error_dialog)); break; case GENERAL_ERROR: builder.setMessage(getString(R.string.general_error_dialog)); break; case UNSUPPORTED_HARDWARE: builder.setMessage(getString(R.string.unsupportet_hardware_dialog)); break; } /*Retry*/ builder.setPositiveButton(R.string.connection_error_dialog_button1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // "restart" mixare startActivity( new Intent(MixContext.getInstance().getApplicationContext(), PluginLoaderActivity.class)); finish(); } }); if (error == GPS_ERROR) { /* Open settings */ builder.setNeutralButton(R.string.connection_error_dialog_button2, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { try { Intent intent1 = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivityForResult(intent1, 42); } catch (Exception e) { Log.d(Config.TAG, "No Location Settings"); } } }); } else if (error == NO_NETWORK_ERROR) { builder.setNeutralButton(R.string.connection_error_dialog_button2, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { try { Intent intent1 = new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS); ComponentName cName = new ComponentName("com.android.phone", "com.android.phone.Settings"); intent1.setComponent(cName); startActivityForResult(intent1, 42); } catch (Exception e) { Log.d(Config.TAG, "No Network Settings"); } } }); } /*Close application*/ builder.setNegativeButton(R.string.connection_error_dialog_button3, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }); AlertDialog alert = builder.create(); alert.show(); }