public class LocationReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { //Do this when the system sends the intent Bundle b = intent.getExtras(); Location loc = (Location)b.get(android.location.LocationManager.KEY_LOCATION_CHANGED); Toast.makeText(context, loc.toString(), Toast.LENGTH_SHORT).show(); } }
mLocationView.setText("Location received: " + location.toString());
/** * Service that receives Location updates. It receives * updates in the background, even if the main Activity is not visible. */ public class LocationIntentService extends IntentService { ... /** * Called when a new location update is available. */ @Override protected void onHandleIntent(Intent intent) { Bundle b = intent.getExtras(); Location loc = (Location) b.get(LocationClient.KEY_LOCATION_CHANGED); Log.d(TAG, "Updated location: " + loc.toString()); } ... }
public void onLocationChanged(Location loc) { Log.d(TAG, loc.toString()); if(/*A condition, which has to stop the service when it´s time*/) { lm.removeUpdates(this); lm = null; stopSelf(); // end this service } }
new MyLocationListener(this, dialog, new MyLocationListener.MyListener() { public void onLocationReceived( Location location ) { text.setText(location.toString()); } }).startTracking();
@Override public void onConnected(Bundle bundle) { LocationServices.FusedLocationApi.setMockMode(mGoogleClient, true); LocationRequest locationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY) .setFastestInterval(5000L) .setInterval(10000L); LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleClient, locationRequest, this); @Override public void onLocationChanged(Location location) { Log.d(TAG, "Location changed!" + location.toString()); }
@Override public String toString() { return l.toString(); }
@Override public String toString() { return this.location.toString() + ", " + this.radius + ", " + this.planter.getName(); } }
/** * Create the marker using API * * @param label the label to write * @param block the block * @param markericon the icon to draw */ private static void addMarker(String label, Location loc, MarkerIcon markericon) { addMarker(loc.toString(), label, loc, markericon); }
/** * Get a string used as unique id for a marker * * @param block the block * @return A unique string for the block */ private static String buildId(Block block) { return block.getLocation().toString(); }
public void showcurrentlocation(View view) { geocoder = new Geocoder(GMapsActivity.this); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); mapView.getOverlays().add(new CircleOverlay(this, location.getLatitude(),location.getLongitude(),325)); if (location != null) { Log.d(TAG, location.toString()); this.onLocationChanged(location); //<6> } populate();
private void handleNewLocation(Location location) { Log.d(TAG, location.toString()); currentLatitude = location.getLatitude(); //update member variable currentLongitude = location.getLongitude(); //update member variable loc = "Latitude: " + Double.toString(currentLatitude) + ", Longitude: " + Double.toString(currentLongitude); Log.v(TAG, loc); }
public void onLocationChanged(Location location) { dummyText.setText(location.toString() + "\n" + "Elapsed Time (ms): " + (lastTime - location.getTime())); lastTime = location.getTime(); }
LocationListener ll = new LocationListener() { @Override public void onLocationChanged(Location arg0) { Toast.makeText(getBaseContext(), "Moved to "+arg0.toString(), Toast.LENGTH_LONG).show(); CameraPosition cp = new CameraPosition.Builder() .target(new LatLng(arg0.getLatitude(),arg0.getLongitude())) .zoom(12) .build(); map.animateCamera(CameraUpdateFactory.newCameraPosition(cp)); } }
private void handleNewLocation(Location location) { Log.d(TAG, location.toString()); double currentLatitude = location.getLatitude(); double currentLongitude = location.getLongitude(); LatLng latLng = new LatLng(currentLatitude, currentLongitude); MarkerOptions options = new MarkerOptions() .position(latLng) .title("I am here!"); mMap.addMarker(options); }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onBlockBurn(BlockBurnEvent event) { Block b = event.getBlock(); String l = b.getLocation().toString(); if (plugin.getGeneralKeeper().getProtectBlockMap().containsKey(l)) { event.setCancelled(true); } } }
@EventHandler public void onRedstoneChange(BlockRedstoneEvent event) { String block = event.getBlock().getLocation().toString(); if (plugin.getGeneralKeeper().getSonicWires().contains(block) || plugin.getGeneralKeeper().getSonicLamps().contains(block) || plugin.getGeneralKeeper().getSonicRails().contains(block)) { event.setNewCurrent(event.getOldCurrent()); } }
@EventHandler(ignoreCancelled = true) public void onPistonRetract(BlockPistonRetractEvent event) { String block = event.getBlock().getLocation().toString(); if (plugin.getGeneralKeeper().getSonicPistons().contains(block)) { event.setCancelled(true); plugin.getGeneralKeeper().getSonicListener().setExtension(event.getBlock()); } } }
@EventHandler(ignoreCancelled = true) public void furnaceSmeltEvent(FurnaceSmeltEvent event) { // Setting cookTime after cooking an item (and the fuel is still burning) Furnace furnace = (Furnace) event.getBlock().getState(); if (furnace.getInventory().getTitle().equals("TARDIS Artron Furnace") && plugin.getTrackerKeeper().getArtronFurnaces().contains(furnace.getLocation().toString())) { if (plugin.isHelperOnServer()) { plugin.getTardisHelper().setCookTimeTotal(event.getBlock(), cookTime); } else { furnace.setCookTime(cookTime); } } }
@EventHandler(ignoreCancelled = true) public void onHarvestPistonRetract(BlockPistonRetractEvent event) { if (!event.isSticky()) { return; } if (plugin.getConfig().getBoolean("preferences.nerf_pistons.only_tardis_worlds") && !event.getBlock().getWorld().getName().contains("TARDIS")) { return; } String block = event.getBlock().getRelative(getOppositeDirection(event.getDirection()), 2).getLocation().toString(); if (plugin.getGeneralKeeper().getProtectBlockMap().containsKey(block)) { event.setCancelled(true); } }