Example usage for android.location Location toString

List of usage examples for android.location Location toString

Introduction

In this page you can find the example usage for android.location Location toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:com.android.camera2.its.ItsSerializer.java

@SuppressWarnings("unchecked")
private static Object serializeLocation(Location loc) throws org.json.JSONException {
    return loc.toString();
}

From source file:com.kylemsguy.fishyfishes.MainActivity.java

public static boolean actuallyRunCheck(final MainActivity activity) {
    if (!activity.playServicesConnected)
        return false;
    Location curr = activity.getCurrentLocation();
    if (curr == null)
        return false;
    if (!PreferenceManager.getDefaultSharedPreferences(activity).getBoolean("location_spoof_enable", false)) {
        me.setPosition(new LatLng(curr.getLatitude(), curr.getLongitude()));

    }//from w ww . j a v a 2s  . c  om
    System.out.println(curr.toString());
    ArrayList<Placemark> marks = getInRangePlaceMarks(curr, getAlertRadiusMeters(activity) * 10);
    final List<Geofence> fences = new ArrayList<Geofence>(marks.size() + 1);
    for (Placemark mark : marks) {
        fences.add(new Geofence.Builder().setRequestId(mark.name)
                .setCircularRegion(mark.lat, mark.lon, getAlertRadiusMeters(activity))
                .setExpirationDuration(Geofence.NEVER_EXPIRE)
                .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER).build());
    }
    final PendingIntent pendingIntent = activity.getGeofencePendingIntent();
    LocationServices.GeofencingApi.removeGeofences(activity.mGoogleApiClient, pendingIntent)
            .setResultCallback(new ResultCallback<Status>() {
                public void onResult(Status s) {
                    if (fences.size() == 0)
                        return;
                    GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
                    builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER);
                    builder.addGeofences(fences);
                    final GeofencingRequest request = builder.build();
                    LocationServices.GeofencingApi.addGeofences(activity.mGoogleApiClient, request,
                            pendingIntent);
                    System.out.println("added geofences: " + fences);
                }
            });
    return false;
}

From source file:de.ncoder.sensorsystem.android.logging.JSONUtils.java

private static Object wrapLocation(Location loc) {
    try {//from  w  w  w.jav  a 2  s  .  c  o  m
        JSONObject json = new JSONObject();
        json.put("provider", loc.getProvider());
        json.put("latitude", loc.getLatitude());
        json.put("longitude", loc.getLongitude());
        if (loc.hasAccuracy())
            json.put("accuracy", loc.getAccuracy());
        json.put("time", loc.getTime());
        if (loc.hasAltitude())
            json.put("alt", loc.getAltitude());
        if (loc.hasSpeed())
            json.put("vel", loc.getSpeed());
        if (loc.hasBearing())
            json.put("bear", loc.getBearing());
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2)
            if (loc.isFromMockProvider())
                json.put("mock", true);
        if (loc.getExtras() != null) {
            json.put("extra", wrap(loc.getExtras()));
        }
        return json;
    } catch (JSONException e) {
        return loc.toString() + " threw " + e.toString();
    }
}

From source file:net.frakbot.android.location.demo.fragment.PlaceholderFragment.java

private void whenLocation(Location location) {
    if (location != null) {
        mLocationTextView.setText(location.toString());
    }
}

From source file:com.hoccer.api.android.LinccLocationManager.java

@Override
public void onLocationChanged(Location location) {
    Log.v("LinccLocationManager", location.toString());
    if (mUpdater != null) {
        mUpdater.updateNow();//from w w w .ja  v a2  s.c o  m
    }
    // try {
    // refreshLocation();
    // } catch (ClientProtocolException e) {
    // // TODO Auto-generated catch block
    // e.printStackTrace();
    // } catch (UpdateException e) {
    // // TODO Auto-generated catch block
    // e.printStackTrace();
    // } catch (IOException e) {
    // // TODO Auto-generated catch block
    // e.printStackTrace();
    // }
}

From source file:com.example.kyle.mapactivity.MapsActivity.java

@Override
public void onLocationChanged(Location location) {
    LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
    textView.setText(location.toString());
}

From source file:pl.wasat.smarthma.utils.loc.FusedLocProviderImpl.java

@Override
public void onLocationChanged(Location location) {
    if (location != null) {
        Log.i(FusedLocProviderImpl.class.getName(), location.toString());
        long timeDiff = System.currentTimeMillis() - updateStartTime;
        if (location.getAccuracy() < ACCURACY_LEVEL || timeDiff > REQUEST_TIMEOUT) {
            fusedLastLocation = location;
            buildAndSendBroadcast(true);
            stopLocationUpdates();//www . ja va2s .  com
        }
    }
}

From source file:com.mifos.mifosxdroid.LocationService.java

@Override
public void onLocationChanged(Location location) {
    path.add(new LatLng(location.getLatitude(), location.getLongitude()));
    Log.i(TAG, "Data update received ~ " + location.toString());
}

From source file:com.google.android.apps.mytracks.samples.api.MainActivity.java

@Override
protected void onStart() {
    super.onStart();

    // use the MyTracks content provider to get all the tracks
    List<Track> tracks = myTracksProviderUtils.getAllTracks();
    for (Track track : tracks) {
        outputTextView.append(track.getId() + " ");

    }//from   w w  w.  ja  va 2  s . c  o  m
    Location loc = myTracksProviderUtils.getLastValidTrackPoint();
    lonTV.setText(loc.toString());

    // start and bind the MyTracks service
    startService(intent);
    bindService(intent, serviceConnection, 0);
}

From source file:de.uni_weimar.m18.anatomiederstadt.element.LocationFragment.java

private void handleNewLocation(Location location) {
    Log.d(LOG_TAG, "Handling location: " + location.toString());
    //double currentLatitude = location.getLatitude();
    //double currentLongitude = location.getLongitude();

    Location target = new Location("target");
    target.setLatitude(Double.parseDouble(mLatitude));
    target.setLongitude(Double.parseDouble(mLongitude));

    float distance = target.distanceTo(location);
    Log.d(LOG_TAG, "Distance to target is approximately " + Float.toString(distance) + "meters");
    if (distance > 25.0f) {
        if (mInfoText != null) {
            String distanceFormat = new DecimalFormat("#").format(distance);
            mInfoText.setText("Du bist noch ca " + distanceFormat + "m entfernt.");
            mInfoText.setVisibility(View.VISIBLE);
        }/*from   www.  j a  v a 2  s.c om*/
    } else {
        // we are in proximity, call action to advance
        mListener.inProximityAction(mTargetId);
    }
}