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:cordova.plugins.Diagnostic.java
public void switchToLocationSettings() { Log.d(TAG, "Switch to Location Settings"); Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); cordova.getActivity().startActivity(settingsIntent); }
From source file:com.ternup.caddisfly.fragment.LocationFragment.java
/** * Invoked by the "Start Updates" button * Sends a request to start location updates * * @param v The view object associated with this method, in this case a Button. *//* ww w . j av a 2 s . c om*/ public void startUpdates(View v) { // Get Location Manager and check for GPS & Network location services LocationManager lm = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); if (!lm.isProviderEnabled(LocationManager.GPS_PROVIDER) || !lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { // Build the alert dialog AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Location Services Not Active"); builder.setMessage("Please enable Location Services and GPS"); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { // Show location settings when the user acknowledges the alert dialog Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent); } }); Dialog alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } else { mUpdatesRequested = true; if (servicesConnected()) { // Turn the indefinite activity indicator on mActivityIndicator.setVisibility(View.VISIBLE); mLocationButton.setVisibility(View.GONE); startPeriodicUpdates(); } } }
From source file:com.elekso.potfix.MainActivity.java
private void showGPSDisabledAlertToUser() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setMessage("Internet & GPS is required by Potfix. Would you like to enable it?") .setCancelable(false).setPositiveButton("Enable GPS", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent callGPSSettingIntent = new Intent( android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(callGPSSettingIntent); }/*from w ww.ja v a2s . c o m*/ }); alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = alertDialogBuilder.create(); alert.show(); }
From source file:org.odk.collect.android.map.OsmMapFragment.java
protected void showGpsDisabledAlert() { gpsErrorDialog = new AlertDialog.Builder(getContext()).setMessage(getString(R.string.gps_enable_message)) .setCancelable(false)//from w ww. ja v a2 s . c o m .setPositiveButton(getString(R.string.enable_gps), (dialog, id) -> startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0)) .setNegativeButton(getString(R.string.cancel), (dialog, id) -> dialog.cancel()).create(); gpsErrorDialog.show(); }
From source file:com.google.transporttracker.TrackerActivity.java
private void reportGpsError() { if (mSwitch != null) { mSwitch.setChecked(false);//from www . j a v a 2s . c o m } Snackbar snackbar = Snackbar .make(findViewById(R.id.rootView), getString(R.string.gps_required), Snackbar.LENGTH_INDEFINITE) .setAction(R.string.enable, new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); } }); // Changing message text color snackbar.setActionTextColor(Color.RED); // Changing action button text color View sbView = snackbar.getView(); TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text); textView.setTextColor(Color.YELLOW); snackbar.show(); }
From source file:com.glm.trainer.NewMainActivity.java
/** * Visualizza una alert per il GPS non abilitato * * @author Gianluca Masci aka (GLM)//from w ww . jav a 2s.co m * */ public void ShowAlertNoGPS() { try { AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(this.getString(R.string.titlegps)); alertDialog.setMessage(this.getString(R.string.messagegpsnoenabled)); alertDialog.setButton(this.getString(R.string.yes), new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(myIntent); } }); alertDialog.setButton2(this.getString(R.string.no), new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { } }); alertDialog.show(); } catch (Exception e) { Toast.makeText(this, "ERROR DIALOG:" + e.getMessage(), Toast.LENGTH_SHORT).show(); Log.e("MEEERR: ", e.getMessage()); } }
From source file:com.safecell.HomeScreenActivity.java
private void launchGPSOptions() { final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent); }
From source file:org.openbmap.activities.HostActivity.java
/** * Checks whether GPS is enabled.//from ww w . j av a2s . com * If not, user is asked whether to activate GPS. */ private void verifyGPSProvider() { final LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE); if (!lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) { // GPS isn't enabled. Offer user to go enable it new AlertDialog.Builder(this).setTitle(R.string.no_gps).setIcon(android.R.drawable.ic_dialog_alert) .setMessage(R.string.turnOnGpsQuestion).setCancelable(true) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); } }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { dialog.cancel(); } }).create().show(); } }
From source file:gov.nasa.arc.geocam.geocam.GeoCamMobile.java
@Override protected Dialog onCreateDialog(int id) { String versionName = "1.0.x"; String versionCode = "XXXX"; String branch = "master"; String commit = "unknown"; String date = "XXXX-XX-XX"; switch (id) { case ABOUT_ID: { try {/* w w w . j a v a2s. c o m*/ branch = getString(R.string.version_git_branch); commit = getString(R.string.version_git_commit); date = getString(R.string.version_date); Log.d(DEBUG_ID, "[branch=" + branch + ";commit=" + commit + ";date=" + date + "]"); } catch (Resources.NotFoundException e) { Log.w(DEBUG_ID, "No version information. Does version.xml exist?"); } try { PackageInfo info = getPackageManager().getPackageInfo(PACKAGE_NAME, PackageManager.GET_GIDS); versionName = info.versionName; versionCode = String.valueOf(info.versionCode); } catch (PackageManager.NameNotFoundException e) { Log.e(DEBUG_ID, "Unable to get version information"); } StringBuilder sb = new StringBuilder(); sb.append(String.format(getString(R.string.main_about_dialog_message_version), date, branch, commit)); sb.append("\n\n"); sb.append(getString(R.string.main_about_dialog_message_contact)); return new AlertDialog.Builder(this) .setTitle(String.format(getString(R.string.main_about_dialog_title), versionName)) .setPositiveButton(R.string.main_about_dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }).setMessage(sb.toString()).create(); } case DIALOG_GPS_OFF_ID: return new AlertDialog.Builder(this).setTitle("Warning").setIcon(android.R.drawable.ic_dialog_alert) .setPositiveButton(R.string.main_gps_warning_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); } }).setNegativeButton(R.string.main_gps_warning_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { GeoCamMobile.this.stopGeoCamService(); GeoCamMobile.this.finish(); } }).setMessage(getString(R.string.main_gps_warning)).create(); } return null; }
From source file:org.ros.android.android_tutorial_teleop.geocam.GeoCamMobile.java
@Override protected Dialog onCreateDialog(int id) { String versionName = "1.0.x"; String versionCode = "XXXX"; String branch = "master"; String commit = "unknown"; String date = "XXXX-XX-XX"; switch (id) { case ABOUT_ID: { try {// w w w. ja va 2s .c o m branch = "getString(R.string.version_git_branch)"; commit = "getString(R.string.version_git_commit)"; date = "getString(R.string.version_date)"; Log.d(DEBUG_ID, "[branch=" + branch + ";commit=" + commit + ";date=" + date + "]"); } catch (Resources.NotFoundException e) { Log.w(DEBUG_ID, "No version information. Does version.xml exist?"); } try { PackageInfo info = getPackageManager().getPackageInfo(PACKAGE_NAME, PackageManager.GET_GIDS); versionName = info.versionName; versionCode = String.valueOf(info.versionCode); } catch (PackageManager.NameNotFoundException e) { Log.e(DEBUG_ID, "Unable to get version information"); } StringBuilder sb = new StringBuilder(); sb.append(String.format(getString(R.string.main_about_dialog_message_version), date, branch, commit)); sb.append("\n\n"); sb.append(getString(R.string.main_about_dialog_message_contact)); return new AlertDialog.Builder(this) .setTitle(String.format(getString(R.string.main_about_dialog_title), versionName)) .setPositiveButton(R.string.main_about_dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }).setMessage(sb.toString()).create(); } case DIALOG_GPS_OFF_ID: return new AlertDialog.Builder(this).setTitle("Warning").setIcon(android.R.drawable.ic_dialog_alert) .setPositiveButton(R.string.main_gps_warning_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); } }).setNegativeButton(R.string.main_gps_warning_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { GeoCamMobile.this.stopGeoCamService(); GeoCamMobile.this.finish(); } }).setMessage(getString(R.string.main_gps_warning)).create(); } return null; }