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:mobisocial.musubi.ui.NearbyActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_nearby); mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); findViewById(R.id.qr).setOnClickListener(new OnClickListener() { @Override//from w w w . jav a 2 s . c o m public void onClick(View v) { IntentIntegrator.initiateScan(NearbyActivity.this); } }); findViewById(R.id.qr).setVisibility(View.GONE); findViewById(R.id.go).setVisibility(View.GONE); DBG = MusubiBaseActivity.isDeveloperModeEnabled(this); setTitle("Nearby"); mAdapter = new NearbyAdapter(this, R.layout.nearby_groups_item, mNearbyList); ListView lv = (ListView) findViewById(android.R.id.list); lv.setAdapter(mAdapter); lv.setOnItemClickListener(this); if (true) { findViewById(R.id.social).setVisibility(View.GONE); } else { setupMulticastScanner(); } EditText tv = (EditText) findViewById(R.id.password); tv.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { synchronized (NearbyActivity.this) { mNearbyList.clear(); mAdapter.notifyDataSetChanged(); } scanNearby(); } }); if (savedInstanceState == null) { UsageMetrics.getUsageMetrics(this).report(MusubiMetrics.VISITED_NEARBY); } String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); if (provider == null || !provider.contains("gps") || !provider.contains("network")) { new AlertDialog.Builder(this).setTitle("Location Settings").setMessage( "You should enable both network-based and GPS-based location services to ensure you can find nearby groups.") .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setPositiveButton("Go to Settings", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(myIntent); } catch (Throwable t) { Log.e(TAG, "failed to launch location settings", t); } } }).show(); } }
From source file:com.findcab.driver.activity.Signup.java
private boolean initGPS() { LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); // GPS????//ww w .j a v a 2s . co m if (!locationManager.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) { Toast.makeText(this, "GPS is not open,Please open it!", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivityForResult(intent, 0); return false; } else { Toast.makeText(this, "GPS is ready", Toast.LENGTH_SHORT); } return true; }
From source file:es.gaedr_space.puntogpsqr.QRVisorFragment.java
/** * Mtodo que muestra un dilogo para configurar el GPS *///from w w w . ja v a 2 s . c om public static void showSettingsAlert(final Context context) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(context); alertDialog.setTitle(context.getString(R.string.gps_settings_title)); alertDialog.setMessage(context.getString(R.string.gps_settings_message)); alertDialog.setPositiveButton(context.getString(R.string.gps_settings_setting), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); context.startActivity(intent); } }); alertDialog.setNegativeButton(context.getString(R.string.gps_settings_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.show(); }
From source file:org.egov.android.view.activity.AllComplaintActivity.java
/** * Function called if the user didnt enable GPS/Location in their device. Give options to enable * GPS/Location and cancel the pop up./*ww w . ja v a 2 s. co m*/ */ public void _showSettingsAlert() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle("Settings"); alertDialog.setMessage("Enable Location Provider! Go to settings menu?"); alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); getActivity().startActivity(intent); } }); alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.show(); }
From source file:com.android.jhansi.designchallenge.MapFragment.java
@Override public void onConnected(Bundle bundle) { Log.i(TAG, "Location services connected."); Location location = null;//from ww w .j a va2s . co m if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { if (!ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION)) { //} else { ActivityCompat.requestPermissions(getActivity(), new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, MY_PERMISSION_ACCESS_FINE_LOCATION); } } else { LocationManager mLocationManager = (LocationManager) getActivity() .getSystemService(Context.LOCATION_SERVICE); if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); } location = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); } if (location == null) { LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this); } else { handleNewLocation(location); } }
From source file:com.popdeem.sdk.core.location.PDLocationManager.java
public static void startLocationSettingsActivity(Context context) { context.startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); }
From source file:com.luke.lukef.lukeapp.tools.LukeUtils.java
/** * Checks the current GPS status, if GPS is not enabled then calls * {@link LukeUtils#alertDialogBuilder(Context, String, String)} to create a prompt for the user * to enable GPS.//from w w w . ja v a 2s.co m * * @param context Context, needed to create the alert. * @return <b>true</b> if the GPS is enabled, <b>false</b> if it's not. */ public static boolean checkGpsStatus(Context context) { final LocationManager manager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { alertDialogBuilder(context, noGps, android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); return false; } else { return true; } }
From source file:com.uproot.trackme.LocationActivity.java
private void enableLocationSettings() { Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(settingsIntent); }
From source file:ca.rmen.android.networkmonitor.app.prefs.PreferenceFragmentActivity.java
@Override public void onOkClicked(int actionId, Bundle extras) { Log.v(TAG, "onClicked, actionId=" + actionId + ", extras = " + extras); mUserInput = true;//from w w w . j a v a 2 s . c o m // Import the database in a background thread. if (actionId == ID_ACTION_IMPORT) { final Uri uri = extras.getParcelable(EXTRA_IMPORT_URI); AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() { @Override protected void onPreExecute() { DialogFragmentFactory.showProgressDialog(PreferenceFragmentActivity.this, getString(R.string.progress_dialog_message), ProgressDialog.STYLE_SPINNER, PROGRESS_DIALOG_FRAGMENT_TAG); } @Override protected Boolean doInBackground(Void... params) { try { Log.v(TAG, "Importing db from " + uri); DBImport.importDB(PreferenceFragmentActivity.this, uri); return true; } catch (Exception e) { Log.e(TAG, "Error importing db: " + e.getMessage(), e); return false; } } @Override protected void onPostExecute(Boolean result) { ProgressDialogFragment dialogFragment = (ProgressDialogFragment) getSupportFragmentManager() .findFragmentByTag(PROGRESS_DIALOG_FRAGMENT_TAG); if (dialogFragment != null) dialogFragment.dismissAllowingStateLoss(); String toastText = result ? getString(R.string.import_successful, uri.getPath()) : getString(R.string.import_failed, uri.getPath()); Toast.makeText(PreferenceFragmentActivity.this, toastText, Toast.LENGTH_SHORT).show(); finish(); } }; task.execute(); } else if (actionId == ID_ACTION_LOCATION_SETTINGS) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent); finish(); } }
From source file:org.voltdb.MainActivity.java
private void identifyLocation() { if (BuildConfig.voter_has_location) { mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE); if (!mLocationManager.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 Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent);/*from www. ja va2 s .c o m*/ } // Define the criteria how to select the locatioin provider -> use default Criteria criteria = new Criteria(); mLocationProvider = mLocationManager.getBestProvider(criteria, false); if (mLocationProvider == null) { mLocationProvider = LocationManager.GPS_PROVIDER; } } }