Example usage for android.provider Settings ACTION_LOCATION_SOURCE_SETTINGS

List of usage examples for android.provider Settings ACTION_LOCATION_SOURCE_SETTINGS

Introduction

In this page you can find the example usage for android.provider Settings ACTION_LOCATION_SOURCE_SETTINGS.

Prototype

String ACTION_LOCATION_SOURCE_SETTINGS

To view the source code for android.provider Settings ACTION_LOCATION_SOURCE_SETTINGS.

Click Source Link

Document

Activity Action: Show settings to allow configuration of current location sources.

Usage

From source file:Main.java

public static void openGPS(Context context) {
    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    context.startActivity(intent);
}

From source file:com.macleod2486.androidswissknife.components.Location.java

@Override
public void onClick(View view) {
    this.activity.startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}

From source file:com.lixplor.fastutil.utils.control.GpsUtil.java

public static void goToGpsSetting() {
    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    sContext.startActivity(intent);/*  www.ja v a 2s.  co  m*/
}

From source file:Main.java

public static void showGPSSettings(final Activity activity) {
    // check for internet connection
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity);
    alertDialog.setTitle("GPS adapter disabled");
    alertDialog.setMessage("GPS is not enabled. Please enable GPS");
    // Setting Positive "Yes" Button
    alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            activity.startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
        }//from   w w  w  .j ava2s.c om
    });
    // Setting Negative "NO" Button
    alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    // Showing Alert Message
    alertDialog.show();
}

From source file:org.developresanddesigners.config_geo_plugin.config_geo_plugin_open.java

public void showSettings() {

    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    config_geo_plugin_open.this.startActivity(intent);
}

From source file:com.spoiledmilk.ibikecph.map.NoGPSDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.dialog_no_gps, container);

    Button btnCancel = (Button) view.findViewById(R.id.btnCancel);
    btnCancel.setTypeface(IbikeApplication.getNormalFont());
    btnCancel.setText(IbikeApplication.getString("leave_no_gps"));
    btnCancel.setOnClickListener(new OnClickListener() {
        @Override//ww w  . j av  a  2 s  .co  m
        public void onClick(View v) {
            getDialog().dismiss();

        }
    });

    TexturedButton btnGPS = (TexturedButton) view.findViewById(R.id.btnActivateGps);
    btnGPS.setBackgroundResource(R.drawable.btn_blue_selector);
    btnGPS.setTextureResource(R.drawable.pattern_btn);
    btnGPS.setTypeface(IbikeApplication.getNormalFont());
    btnGPS.setTextColor(Color.WHITE);
    btnGPS.setText(IbikeApplication.getString("activate_gps"));
    btnGPS.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
            getDialog().dismiss();
        }
    });

    ((TextView) view.findViewById(R.id.textTitle)).setText(IbikeApplication.getString("gps_off"));
    ((TextView) view.findViewById(R.id.textTitle)).setTypeface(IbikeApplication.getBoldFont());
    getDialog().getWindow().requestFeature(STYLE_NO_TITLE);

    return view;
}

From source file:net.quranquiz.ui.QQMap.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map);// w  w  w. j a  va  2 s  . c  o m
    map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    map.setOnMarkerClickListener((OnMarkerClickListener) this);

    cairo = new LatLng(30.1, 31.45);

    LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE);
    boolean enabledGPS = service.isProviderEnabled(LocationManager.GPS_PROVIDER);

    // Check if enabled and if not send user to the GSP settings
    // Better solution would be to display a dialog and suggesting to 
    // go to the settings
    if (!enabledGPS) {
        Toast.makeText(this, "GPS signal not found", Toast.LENGTH_LONG).show();
        startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
    }

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    criteria.setAltitudeRequired(false);
    criteria.setBearingRequired(false);
    criteria.setCostAllowed(true);
    criteria.setPowerRequirement(Criteria.POWER_LOW);
    provider = locationManager.getBestProvider(criteria, true);
    Location location = locationManager.getLastKnownLocation(provider);

    // Initialize the location fields
    if (location != null) {
        Toast.makeText(this, "Selected Provider " + provider, Toast.LENGTH_SHORT).show();
        meMarker = map.addMarker(
                new MarkerOptions().position(cairo).title("That's Me").snippet("a normal QuranQuiz Node!")
                        .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)));

        map.moveCamera(CameraUpdateFactory.newLatLngZoom(cairo, 12.0f));

        onLocationChanged(location);
    } else {

        //do something
    }

}

From source file:org.odk.collect.android.fragments.dialogs.LocationProvidersDisabledDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    setCancelable(false);/*from  w w w. ja va2  s  . c o  m*/

    return new AlertDialog.Builder(getActivity()).setIcon(R.drawable.ic_place_black)
            .setTitle(R.string.provider_disabled_error)
            .setMessage(R.string.location_providers_disabled_dialog_message)
            .setPositiveButton(R.string.go_to_settings, (dialog, id) -> {
                startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
            }).setNegativeButton(R.string.cancel, (dialog, id) -> {
            }).create();
}

From source file:com.yammy.meter.map.MainMapBengkel.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.isvo_map_bengkel);
    this.jarak = (TextView) this.findViewById(R.id.map_bengkel_length);

    int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
    if (result != ConnectionResult.SUCCESS) {
        GooglePlayServicesUtil.getErrorDialog(result, MainMapBengkel.this, 1).show();
    } else {/*  ww w .  j  a  v  a2  s.c  o  m*/
        map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
        GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getBaseContext());

        map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        map.setIndoorEnabled(false);
        bundle = getIntent().getExtras();
        try {
            data_pos = new LatLng(Double.parseDouble(bundle.getString("lat")),
                    Double.parseDouble(bundle.getString("long")));
            Toast.makeText(getBaseContext(), bundle.getString("lat") + "," + bundle.getString("long"),
                    Toast.LENGTH_LONG).show();
        } catch (NumberFormatException e) {
            Toast.makeText(getBaseContext(), "Mencari lokasi saat ini", Toast.LENGTH_SHORT).show();
        }

        /**
         * mulai edan dari ini ke bawah
         */
        LocationManager service = (LocationManager) this.getSystemService(LOCATION_SERVICE);
        boolean enabledGPS = service.isProviderEnabled(LocationManager.GPS_PROVIDER);
        if (!enabledGPS) {
            Toast.makeText(this, "GPS tidak ditemukan", Toast.LENGTH_LONG).show();
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            startActivity(intent);
        }
        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 0, this);
        if (location != null && location.getTime() > Calendar.getInstance().getTimeInMillis() - 2 * 60 * 1000) {
            Toast.makeText(getApplicationContext(),
                    "Current Location : " + location.getLatitude() + "," + location.getLongitude(),
                    Toast.LENGTH_LONG).show();
            drawMarker(location);
        } else {
            locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
        }
    }
}

From source file:com.collectme.cordova.calgeolocation.CalGeolocation.java

/**
 * Requests that the user enable the location in device settings.
 *///from  w w w.  ja v a 2  s. c  om
public void switchToLocationSettings() {
    Log.d(TAG, "Switch to Location Settings");
    Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    cordova.getActivity().startActivity(settingsIntent);
}