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 . 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
Source File: BleDevicesFragment.java    From bleYan with GNU General Public License v2.0 6 votes vote down vote up
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 File: PlacesActivity.java    From nearby-android with 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
Source File: ActivitySettings.java    From FineGeotag with GNU General Public License v3.0 5 votes vote down vote up
@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
Source File: NotificationHelper.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 File: GoogleLocationUtils.java    From mytracks with 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
Source File: MapActivity.java    From nongbeer-mvp-android-demo with Apache License 2.0 5 votes vote down vote up
private void startMap(){
    if( isLocationEnable() ){
        mapFragment.getMapAsync( this );
    }else{
        Intent myIntent = new Intent( Settings.ACTION_LOCATION_SOURCE_SETTINGS );
        startActivity( myIntent );
    }
}
 
Example 7
Source File: BleManager.java    From SweetBlue with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 File: EasyLocationDelegate.java    From Android-EasyLocation with Apache License 2.0 4 votes vote down vote up
private void openLocationSettings() {
    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    activity.startActivityForResult(intent, ENABLE_LOCATION_SERVICES_REQUEST);
}
 
Example 9
Source File: SettingsUtil.java    From react-native-get-location with 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 10
Source File: LocationUtils.java    From 365browser with 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 11
Source File: EstablishmentFragment.java    From Saude-no-Mapa with 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 12
Source File: EasyLocationDelegate.java    From EasyLocation with Apache License 2.0 4 votes vote down vote up
private void openLocationSettings() {
    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    activity.startActivityForResult(intent, ENABLE_LOCATION_SERVICES_REQUEST);
}
 
Example 13
Source File: LocationUtils.java    From AndroidUtilCode with 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 14
Source File: AndroidLocationProvider.java    From BLE-Indoor-Positioning with Apache License 2.0 4 votes vote down vote up
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 15
Source File: Util.java    From androidnative.pri with 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 16
Source File: AppUtils.java    From SampleApp with 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 17
Source File: IntentUtils.java    From android-intents with 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 18
Source File: MainActivity.java    From HereGPSLocation with GNU General Public License v3.0 4 votes vote down vote up
private void clickCheckBox() {
	Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
	startActivity(intent);
	checkBox.setChecked(locationManager.isProviderEnabled("gps"));
}
 
Example 19
Source File: ScannerActivity.java    From mcumgr-android with 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 20
Source File: BasePlatformCreate.java    From indigenous-android with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Open location settings.
 */
private void enableLocationSettings() {
    Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    startActivity(settingsIntent);
}