Java Code Examples for android.provider.Settings#ACTION_LOCATION_SOURCE_SETTINGS

The following examples show how to use android.provider.Settings#ACTION_LOCATION_SOURCE_SETTINGS . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public void displayPromptForEnablingGPS() {
    final String action = Settings.ACTION_LOCATION_SOURCE_SETTINGS;


    new MaterialDialog.Builder(getActivity())
            .title(R.string.label_request_open_gps_title)
            .content(R.string.label_request_open_gps_content)
            .positiveText(R.string.label_ok)
            .onPositive(new MaterialDialog.SingleButtonCallback() {

                @Override
                public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
                    startActivityForResult(new Intent(action), REQUEST_CODE_OPEN_GPS);
                }
            })
            .negativeText(R.string.label_cancel)
            .cancelable(true)
            .negativeText(R.string.label_cancel)
            .show();
}
 
Example 2
Source Project: nearby-android   File: PlacesActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void checkSettings() {
  // Is GPS enabled?
  final boolean gpsEnabled = locationTrackingEnabled();
  // Is there internet connectivity?
  final boolean internetConnected = internetConnectivity();

  if (gpsEnabled && internetConnected) {
    completeSetUp();
  } else if (!gpsEnabled) {
    final Intent gpsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    showDialog(gpsIntent, REQUEST_LOCATION_SETTINGS, getString(R.string.location_tracking_off));
  } else {
    final Intent internetIntent = new Intent(Settings.ACTION_WIFI_SETTINGS);
    showDialog(internetIntent, REQUEST_WIFI_SETTINGS, getString(R.string.wireless_off));
  }
}
 
Example 3
@Override
protected void onResume() {
    super.onResume();
    getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);

    SharedPreferences prefs = getPreferenceScreen().getSharedPreferences();

    // Get preferences
    Preference pref_check = findPreference(PREF_CHECK);
    Preference pref_version = findPreference(PREF_VERSION);

    // Set summaries
    onSharedPreferenceChanged(prefs, PREF_ENABLED);
    onSharedPreferenceChanged(prefs, PREF_TOAST);
    onSharedPreferenceChanged(prefs, PREF_ALTITUDE);
    onSharedPreferenceChanged(prefs, PREF_ACCURACY);
    onSharedPreferenceChanged(prefs, PREF_TIMEOUT);
    onSharedPreferenceChanged(prefs, PREF_KNOWN);

    // Location settings
    Intent locationSettingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    if (getPackageManager().queryIntentActivities(locationSettingsIntent, 0).size() > 0)
        pref_check.setIntent(locationSettingsIntent);
    else
        pref_check.setEnabled(false);

    // Version
    Intent playStoreIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName()));
    if (getPackageManager().queryIntentActivities(playStoreIntent, 0).size() > 0)
        pref_version.setIntent(playStoreIntent);
    try {
        PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        pref_version.setSummary(
                pInfo.versionName + "/" + pInfo.versionCode + "\n" +
                        getString(R.string.msg_geocoder) + " " +
                        getString(Geocoder.isPresent() ? R.string.msg_yes : R.string.msg_no));
    } catch (PackageManager.NameNotFoundException ignored) {
    }
}
 
Example 4
private static void showLocationNotification(Context context, String title, String info) {
    NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    Intent locationSettings = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    PendingIntent intentNotify = PendingIntent.getActivity(context, 0, locationSettings, PendingIntent.FLAG_CANCEL_CURRENT);

    NotificationCompat.Builder builder = createBuilder(context, R.string.location_accuracy)
            .setContentIntent(intentNotify)
            .setAutoCancel(true)
            .setSmallIcon(R.drawable.ic_location)
            .setContentTitle(title)
            .setContentText(info)
            .setTicker(title);

    manager.notify(NOTIFICATION_GPS_ID, builder.build());
}
 
Example 5
Source Project: mytracks   File: GoogleLocationUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new location settings intent.
 * 
 * @param context the context
 */
public static Intent newLocationSettingsIntent(Context context) {
  Intent intent = new Intent(useGoogleLocationSettings(context) ? ACTION_GOOGLE_LOCATION_SETTINGS
      : Settings.ACTION_LOCATION_SOURCE_SETTINGS);
  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  return intent;
}
 
Example 6
private void startMap(){
    if( isLocationEnable() ){
        mapFragment.getMapAsync( this );
    }else{
        Intent myIntent = new Intent( Settings.ACTION_LOCATION_SOURCE_SETTINGS );
        startActivity( myIntent );
    }
}
 
Example 7
/**
 * Overload of {@link #turnOnLocationWithIntent_forOsServices(Activity, int)} if you don't care about result.
 *
 * @see com.idevicesinc.sweetblue.utils.BluetoothEnabler
 */
public final void turnOnLocationWithIntent_forOsServices(final Activity callingActivity)
{
	final Intent enableLocationIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);

	callingActivity.startActivity(enableLocationIntent);

	if( false == Utils.isMarshmallow() )
	{
		m_logger.w("You may use this method but since the phone is at " + Build.VERSION.SDK_INT + " and the requirement is "+Build.VERSION_CODES.M+", it is not necessary for scanning.");
	}
}
 
Example 8
Source Project: react-native-get-location   File: SettingsUtil.java    License: MIT License 4 votes vote down vote up
public static void openGpsSettings(final Context context) {
    final String action = Settings.ACTION_LOCATION_SOURCE_SETTINGS;
    Intent intent = new Intent(action);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    context.startActivity(intent);
}
 
Example 9
/**
 * Open location settings.
 */
private void enableLocationSettings() {
    Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    startActivity(settingsIntent);
}
 
Example 10
Source Project: mcumgr-android   File: ScannerActivity.java    License: Apache License 2.0 4 votes vote down vote up
@OnClick(R.id.action_enable_location)
public void onEnableLocationClicked() {
    final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    startActivity(intent);
}
 
Example 11
private void clickCheckBox() {
	Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
	startActivity(intent);
	checkBox.setChecked(locationManager.isProviderEnabled("gps"));
}
 
Example 12
Source Project: android-intents   File: IntentUtils.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Open system settings location services screen for turning on/off GPS
 */
public static Intent showLocationServices() {
    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    return intent;
}
 
Example 13
Source Project: SampleApp   File: AppUtils.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Redirect user to enable GPS
 */
public void goToGpsSettings() {
    Intent callGPSSettingIntent = new Intent(
            Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    mContext.startActivity(callGPSSettingIntent);
}
 
Example 14
Source Project: androidnative.pri   File: Util.java    License: Apache License 2.0 4 votes vote down vote up
static void openGPSSettings() {
      Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
      Activity activity = org.qtproject.qt5.android.QtNative.activity();
      activity.startActivity(intent);
}
 
Example 15
public static void requestLocationEnabling(@NonNull Activity activity) {
    Log.d(TAG, "Requesting location enabling");
    Intent locationSettings = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    activity.startActivity(locationSettings);
}
 
Example 16
Source Project: AndroidUtilCode   File: LocationUtils.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 打开Gps设置界面
 */
public static void openGpsSettings() {
    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    Utils.getApp().startActivity(intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
 
Example 17
private void openLocationSettings() {
    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    activity.startActivityForResult(intent, ENABLE_LOCATION_SERVICES_REQUEST);
}
 
Example 18
Source Project: Saude-no-Mapa   File: EstablishmentFragment.java    License: MIT License 4 votes vote down vote up
@Override
public void startGpsIntent() {
    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    startActivityForResult(intent, 202);
}
 
Example 19
Source Project: 365browser   File: LocationUtils.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Returns an intent to launch Android Location Settings.
 */
public Intent getSystemLocationSettingsIntent() {
    Intent i = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return i;
}
 
Example 20
private void openLocationSettings() {
    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    activity.startActivityForResult(intent, ENABLE_LOCATION_SERVICES_REQUEST);
}