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.asc.msigeosystems.prism4d.YGPS.java
/** Called when the activity is first created. */ @Override/*from w w w . j a va 2 s . co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getLayout()); //GPS Stuff //Make sure we have the proper GPS permissions before starting //If we don't currently have permission, bail if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { return; } mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mLocationManager.requestLocationUpdates("gps", 0, 0.0f, this); mLocationManager.addGpsStatusListener(this); //mLocationManager.addNmeaListener(this); mPositionView = (SatellitePositionView) findViewById(R.id.positionview); mSignalView = (SatelliteSignalView) findViewById(R.id.signalview); mGpsState = (GPSStateView) findViewById(R.id.gpsstate); mLatitude = getField(R.id.latitude, "Latitude", "degrees"); mLongitude = getField(R.id.longitude, "Longitude", "degrees"); mAccuracy = getField(R.id.accuracy, "Accuracy", "m"); mAltitude = getField(R.id.altitude, "Altitude", "m", "#.#"); mSpeed = getField(R.id.speed, "Speed", "kmh", "#.###"); mBearing = getField(R.id.bearing, "Bearing", "degrees"); mTime = getDateField(R.id.time, "GPS Time", ""); mDeviceTime = getDateField(R.id.devicetime, "Device Time", ""); mSatInSky = getField(R.id.satinsky, "Sat in Sky", ""); mSatInFix = getField(R.id.satinfix, "Sat in Fix", ""); mTtff = getField(R.id.ttff, "Time to first fix", "ms"); mTslf = getField(R.id.tslf, "Time since last fix", "mmm:ss"); mHandler = new Handler(); mLastFixUpdater = new LastFixUpdater(); mHandler.post(mLastFixUpdater); }
From source file:com.beyondar.example.BeyondarLocationManagerMapActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map_google); Button myLocationButton = (Button) findViewById(R.id.myLocationButton); myLocationButton.setVisibility(View.VISIBLE); myLocationButton.setOnClickListener(this); mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); if (mMap == null) { return;//from w w w .j a v a2 s.com } // We create the world and fill the world mWorld = CustomWorldHelper.generateObjects(this); // As we want to use GoogleMaps, we are going to create the plugin and // attach it to the World mGoogleMapPlugin = new GoogleMapWorldPlugin(this); // Then we need to set the map in to the GoogleMapPlugin mGoogleMapPlugin.setGoogleMap(mMap); // Now that we have the plugin created let's add it to our world. // NOTE: It is better to load the plugins before start adding object in // to the world. mWorld.addPlugin(mGoogleMapPlugin); mMap.setOnMarkerClickListener(this); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mGoogleMapPlugin.getLatLng(), 15)); mMap.animateCamera(CameraUpdateFactory.zoomTo(19), 2000, null); // Lets add the user position to the map GeoObject user = new GeoObject(1000l); user.setGeoPosition(mWorld.getLatitude(), mWorld.getLongitude()); user.setImageResource(R.drawable.flag); user.setName("User position"); mWorld.addBeyondarObject(user); BeyondarLocationManager.addWorldLocationUpdate(mWorld); BeyondarLocationManager.addGeoObjectLocationUpdate(user); // We need to set the LocationManager to the BeyondarLocationManager. BeyondarLocationManager.setLocationManager((LocationManager) getSystemService(Context.LOCATION_SERVICE)); }
From source file:com.facebook.samples.placepicker.PlacePickerSampleActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);// ww w .j a va 2s. c o m resultsTextView = (TextView) findViewById(R.id.resultsTextView); Button button = (Button) findViewById(R.id.seattleButton); button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickSeattle(); } }); button = (Button) findViewById(R.id.sanFranciscoButton); button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickSanFrancisco(); } }); button = (Button) findViewById(R.id.gpsButton); button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickGPS(); } }); lifecycleHelper = new UiLifecycleHelper(this, new Session.StatusCallback() { @Override public void call(Session session, SessionState state, Exception exception) { onSessionStateChanged(session, state, exception); } }); lifecycleHelper.onCreate(savedInstanceState); ensureOpenSession(); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); }
From source file:com.oneplusar.example.OnePlusARLocationManagerMapActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map_google); Button myLocationButton = (Button) findViewById(R.id.myLocationButton); myLocationButton.setVisibility(View.VISIBLE); myLocationButton.setOnClickListener(this); mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); if (mMap == null) { return;/*from w w w.j a v a 2s .c om*/ } // We create the world and fill the world mWorld = CustomWorldHelper.generateObjects(this); // As we want to use GoogleMaps, we are going to create the plugin and // attach it to the World mGoogleMapPlugin = new GoogleMapWorldPlugin(this); // Then we need to set the map in to the GoogleMapPlugin mGoogleMapPlugin.setGoogleMap(mMap); // Now that we have the plugin created let's add it to our world. // NOTE: It is better to load the plugins before start adding object in // to the world. mWorld.addPlugin(mGoogleMapPlugin); mMap.setOnMarkerClickListener(this); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mGoogleMapPlugin.getLatLng(), 15)); mMap.animateCamera(CameraUpdateFactory.zoomTo(19), 2000, null); // Lets add the user position to the map GeoObject user = new GeoObject(1000l); user.setGeoPosition(mWorld.getLatitude(), mWorld.getLongitude()); user.setImageResource(R.drawable.flag); user.setName("User position"); mWorld.addOnePlusARObject(user); OnePlusARLocationManager.addWorldLocationUpdate(mWorld); OnePlusARLocationManager.addGeoObjectLocationUpdate(user); // We need to set the LocationManager to the OnePlusARLocationManager. OnePlusARLocationManager.setLocationManager((LocationManager) getSystemService(Context.LOCATION_SERVICE)); }
From source file:com.example.scandevice.GeofenceTransitionsIntentService.java
private void initializeLocationManager() { Log.e(TAG, "initializeLocationManager"); if (mLocationManager == null) { mLocationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE); }/*w ww .j a va 2 s. c o m*/ }
From source file:com.neton.cordova.diagnostic.Diagnostic.java
private boolean isLocationProviderEnabled(String provider) { LocationManager locationManager = (LocationManager) cordova.getActivity() .getSystemService(Context.LOCATION_SERVICE); return locationManager.isProviderEnabled(provider); }
From source file:com.fallahpoor.infocenter.fragments.gps.GpsFragment.java
public boolean hasGpsFeature() { LocationManager locationManager = (LocationManager) getActivity() .getSystemService(Context.LOCATION_SERVICE); if (locationManager == null) { return false; }//from w w w. ja va2 s.c om Iterator<String> iterator = locationManager.getAllProviders().iterator(); String provider; while (iterator.hasNext()) { provider = iterator.next(); if (provider.equals(LocationManager.GPS_PROVIDER)) { return true; } } return false; }
From source file:com.vonglasow.michael.satstat.PasvLocListenerService.java
@Override public void onCreate() { super.onCreate(); //do we need that here? mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); registerReceiver(mGpsStatusReceiver, new IntentFilter(GpsEventReceiver.GPS_ENABLED_CHANGE)); registerReceiver(mGpsStatusReceiver, new IntentFilter(GpsEventReceiver.GPS_FIX_CHANGE)); }
From source file:com.manuelmazzuola.speedtogglebluetooth.service.MonitorSpeed.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { running = Boolean.TRUE;// w w w . j a va 2 s . c om lm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); provider = lm.NETWORK_PROVIDER; oldLocation = lm.getLastKnownLocation(provider); IntentFilter filters = new IntentFilter(); // When to turn off bluetooth filters.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); // When hold bluetooth on filters.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); // When user directly turn on or off bluetooth filters.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); registerReceiver(bluetoothListener, filters); lm.requestLocationUpdates(provider, 45 * 1000, 0f, this); Intent stopIntent = new Intent(this, MainActivity.class); stopIntent.putExtra("close", "close"); PendingIntent stopPendingIntent = PendingIntent.getActivity(this, 0, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder note = new NotificationCompat.Builder(getApplicationContext()) .setContentTitle(DEFAULT_TITLE).setContentText(DEFAULT_MESSAGE) .setDefaults(Notification.DEFAULT_VIBRATE).setAutoCancel(true).setContentIntent(stopPendingIntent) .setSmallIcon(R.drawable.ic_action_bluetooth); note.getNotification().flags |= Notification.FLAG_AUTO_CANCEL; Notification notification = note.build(); notification.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL; startForeground(intentId, note.build()); return START_NOT_STICKY; }
From source file:com.guidewithme.ArticleInfoListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mLocationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); // Restore the previously serialized activated item position. if (savedInstanceState != null && savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION)); }