List of usage examples for android.content Context LOCATION_SERVICE
String LOCATION_SERVICE
To view the source code for android.content Context LOCATION_SERVICE.
Click Source Link
From source file:com.chalmers.schmaps.GoogleMapSearchLocation.java
/** * method is called from onCreate() and it initiates the variables * used in GoogleMapSearchLocation/*from w w w . ja va2 s . c o m*/ */ private void assignInstances() { setContentView(R.layout.activity_map); //Fields used only once. Button editButton, directionsButton; Criteria criteria; String bestProvider; Drawable room, student; mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); mapOverlays = mapView.getOverlays(); room = this.getResources().getDrawable(R.drawable.dot); student = this.getResources().getDrawable(R.drawable.chalmersandroid); mapItemizedRoom = new MapItemizedOverlay(room, this); mapItemizedStudent = new MapItemizedOverlay(student, this); editButton = (Button) findViewById(R.id.edittextbutton); directionsButton = (Button) findViewById(R.id.directionbutton); lectureEdit = (EditText) findViewById(R.id.edittextlecture); editButton.setOnClickListener(this); directionsButton.setOnClickListener(this); locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); //deafult criteria criteria = new Criteria(); //best reception bestProvider = locationManager.getBestProvider(criteria, false); //gets last known location from chosen provider location = locationManager.getLastKnownLocation(bestProvider); roomSearched = false; running = false; }
From source file:com.github.tdudziak.gps_lock_lock.LockService.java
private void enable() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); mLockTime = prefs.getInt("lockTime", 5); mStartTime = System.currentTimeMillis(); mNotificationUi.enable(); // setup UI requestUiUpdate(); // start broadcasting UI update intents // Setup GPS listening. mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, GPS_MIN_TIME, 0, this); mIsActive = true;//from ww w.j a v a 2 s . c o m Log.i(TAG, "enable()"); }
From source file:org.metawatch.manager.Monitors.java
public static void start(Context context, TelephonyManager telephonyManager) { // start weather updater if (Preferences.logging) Log.d(MetaWatch.TAG, "Monitors.start()"); createBatteryLevelReciever(context); createWifiReceiver(context);// w ww . ja v a 2 s . co m if (Preferences.weatherGeolocation) { if (Preferences.logging) Log.d(MetaWatch.TAG, "Initialising Geolocation"); try { locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); locationProvider = LocationManager.NETWORK_PROVIDER; networkLocationListener = new NetworkLocationListener(context); locationManager.requestLocationUpdates(locationProvider, 30 * 60 * 1000, 500, networkLocationListener); RefreshLocation(); } catch (IllegalArgumentException e) { if (Preferences.logging) Log.d(MetaWatch.TAG, "Failed to initialise Geolocation " + e.getMessage()); } } else { if (Preferences.logging) Log.d(MetaWatch.TAG, "Geolocation disabled"); } CallStateListener phoneListener = new CallStateListener(context); telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); int phoneEvents = PhoneStateListener.LISTEN_CALL_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE; telephonyManager.listen(phoneListener, phoneEvents); if (Utils.isGmailAccessSupported(context)) { gmailMonitor = new GmailMonitor(context); gmailMonitor.startMonitor(); } try { contentObserverMessages = new ContentObserverMessages(context); Uri uri = Uri.parse("content://mms-sms/conversations/"); contentResolverMessages = context.getContentResolver(); contentResolverMessages.registerContentObserver(uri, true, contentObserverMessages); } catch (Exception x) { } try { contentObserverCalls = new ContentObserverCalls(context); //Uri uri = Uri.parse("content://mms-sms/conversations/"); contentResolverCalls = context.getContentResolver(); contentResolverCalls.registerContentObserver(android.provider.CallLog.Calls.CONTENT_URI, true, contentObserverCalls); } catch (Exception x) { } try { contentObserverAppointments = new ContentObserverAppointments(context); Uri uri = Uri.parse("content://com.android.calendar/calendars/"); contentResolverAppointments = context.getContentResolver(); contentResolverAppointments.registerContentObserver(uri, true, contentObserverAppointments); } catch (Exception x) { } // temporary one time update updateWeatherData(context); startAlarmTicker(context); }
From source file:com.example.administrator.myapplication2._5_Group._5_Group.RightFragment.java
/** * ?? ? // w ww.j av a 2 s . co m */ private void startLocationService() { // ? ? manager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); // ? ? ? gpsListener = new GPSListener(); long minTime = 5000;//GPS - 20 float minDistance = 1;//?? (10m) // GPS manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, minTime, minDistance, gpsListener); // ? manager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, minTime, minDistance, gpsListener); }
From source file:com.waz.zclient.pages.main.conversation.LocationFragment.java
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (isGooglePlayServicesAvailable()) { googleApiClient = new GoogleApiClient.Builder(getContext()).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(LocationServices.API).build(); } else {//from w ww .jav a2 s .c om locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); } mainHandler = new Handler(); handlerThread = new HandlerThread("Background handler"); handlerThread.start(); backgroundHandler = new Handler(handlerThread.getLooper()); geocoder = new Geocoder(getContext(), Locale.getDefault()); zoom = true; }
From source file:it.unipr.informatica.autobusparma.MappaFragment.java
private void updatePlaces() { locMan = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); Location lastLoc = getLocation(MIN_DISTANCE_CHANGE_FOR_UPDATES, MIN_TIME_BW_UPDATES); if (lastLoc != null) { double myLat = lastLoc.getLatitude(); double myLon = lastLoc.getLongitude(); LatLng myL = new LatLng(myLat, myLon); mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(myL, 15)); if (userMarker != null) userMarker.remove();/*from w w w . j a v a 2 s .com*/ String placesSearchStr = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=" + myLat + "," + myLon + "&radius=10000&sensor=true&keyword=autobus&key=INSERT KEY"; /*String placesSearchStr = null; Log.d("prova", "p"); try { placesSearchStr = leggiFiles(); } catch (IOException e) { // TODO Auto-generated catch block Log.d("prova", "sono nel catch"); e.printStackTrace(); }*/ //execute query new GetPlaces().execute(placesSearchStr); //onPostExecute(placesSearchStr); } if (isGPSEnabled) { locMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this); } }
From source file:com.example.david.wheretogo_test1.PickerActivity.java
@Override protected void onStop() { super.onStop(); if (locationListener != null) { LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationManager.removeUpdates(locationListener); locationListener = null;/* w ww. jav a2 s .c o m*/ } }
From source file:com.mibr.android.intelligentreminder.INeedToo.java
public LocationManager getLocationManager() { if (mLocationManager == null) { mLocationManager = (android.location.LocationManager) getSystemService(Context.LOCATION_SERVICE); }/* www .j a v a 2 s .c om*/ if (_bestProvider == null) { Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); _bestProvider = mLocationManager.getBestProvider(criteria, false); mLocationManager.requestLocationUpdates(_bestProvider, 20000, 10, this); } return mLocationManager; }
From source file:com.stfalcon.hromadskyipatrol.ui.activity.MainActivity.java
private boolean checkLocationManager() { if (!((LocationManager) getSystemService(Context.LOCATION_SERVICE)) .isProviderEnabled(LocationManager.GPS_PROVIDER)) { if (!isGPSDialogShowed) { LocationDialog.showSettingsAlert(this); isGPSDialogShowed = true;/*from w w w. j a v a2s . c o m*/ } return false; } return true; }
From source file:com.example.angelina.travelapp.places.PlacesActivity.java
private boolean locationTrackingEnabled() { final LocationManager locationManager = (LocationManager) getApplicationContext() .getSystemService(Context.LOCATION_SERVICE); return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); }