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.tbay.android.FrequentSMS.MainActivity.java

private void handleNewLocation(Location loc) {

    Log.i(TAG, loc.toString());
}

From source file:edu.poly.cs9033.nowaiting.service.LocationReceiver.java

private void uploadCurrentLocation(Location location) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("command", "UPDATE_LOCATION");
    params.put("latitude", location.getLatitude());
    params.put("longitude", location.getLongitude());
    params.put("datetime", String.valueOf((System.currentTimeMillis() / 1000L)));
    Logger.i("Uploading location info to server:" + location.toString());
    JSONObject response = new JSONParser().makeHttpRequest(MainActivity.SERVER_URL, params);
    if (response == null) {
        Logger.e("can't talk with the server,JSON response is null");
    } else {//  w w  w .j  a va  2  s.co m
        Integer responseCode = -100;
        try {
            responseCode = (Integer) response.get("response_code");
            if (responseCode != 0)
                Logger.e("http request to the server failed,reason:" + response.get("error_string"));
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

From source file:org.lytsing.android.weibo.ui.ComposeActivity.java

public void locationCb(String url, Location loc, AjaxStatus status) {

    if (loc != null) {
        Log.d("Location:" + loc.toString());
        mLatitude = String.valueOf(loc.getLatitude());
        mLongitude = String.valueOf(loc.getLongitude());

        //PlaceAPI api = new PlaceAPI(mAccessToken);
        //api.nearbyPois(mLatitude, mLongitude, range, q, category, count, page, offset, listener);

        mIsLocation = true;/*from  www .  j  ava  2  s . c om*/

        aq.id(R.id.ly_loadlocation).gone();
        aq.id(R.id.tv_location).visible();
        aq.id(R.id.ib_insert_location).image(R.drawable.btn_insert_location_nor_2);
    } else {
        Log.w("loc is null!");
    }
}

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

public void sendLoc(double lat, double lon) {
    LocationServices.FusedLocationApi.setMockMode(mGoogleApiClient, true);
    Location loc = new Location("network");

    loc.setLatitude(lat);/*from   ww w .  ja  va2 s.  c o  m*/
    loc.setLongitude(lon);
    System.out.println(loc.toString());
    loc.setAccuracy(10);
    loc.setTime(System.currentTimeMillis());
    loc.setElapsedRealtimeNanos(1);
    LocationServices.FusedLocationApi.setMockLocation(mGoogleApiClient, loc);
}

From source file:com.example.groupproject.Model.LocationReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.d("recieved", "received!");
    _context = context;/*from ww  w  .j  ava  2 s.c  om*/
    Bundle b = intent.getExtras();
    LocationPollerResult locationResult = new LocationPollerResult(b);

    Location loc = locationResult.getLocation();
    String msg;
    if (loc == null) {
        loc = locationResult.getLastKnownLocation();

        if (loc == null) {
            msg = locationResult.getError();
        } else {
            msg = "TIMEOUT, lastKnown=" + loc.toString();
        }
    } else {
        List<Zone> zones = getZones();
        countPoints(zones, loc.getLongitude(), loc.getLatitude());
        msg = loc.toString();
    }

    if (msg == null) {
        msg = "Invalid broadcast received!";
    }
    Log.d("MSG", msg + " " + points);
}

From source file:hack.ddakev.roadrant.MainActivity.java

@Override
public void onLocationChanged(Location location) {
    System.out.println(location.toString());
    if (location != null) {
        lat = location.getLatitude();/*from w w w  . j  ava  2  s  . c  o  m*/
        lon = location.getLongitude();
    }
}

From source file:org.opensmc.mytracks.cyclesmc.MainInput.java

private void makeUseOfNewLocation(Location location) {
    System.out.println(location.toString());
    System.out.println("Here.");
    //((RideIndegoAdapter)nearbyStations.getAdapter()).removeAll();
    //        debugLocation = (TextView) findViewById(R.id.locationDebug);
    //        debugLocation.setText(location.toString());
}

From source file:gob.sct.android.checatucell.services.LocationReceiver.java

/***
 * Makes a call to the location service and gets current user's location
 * *//*w ww  . j ava  2 s  .com*/
private Location getLocationUpdate(Bundle mBundle, Intent mIntent) {

    String message;

    Location location = (Location) mBundle.get(LocationPoller.EXTRA_LOCATION);

    if (location == null) {
        location = (Location) mBundle.get(LocationPoller.EXTRA_LASTKNOWN);
        if (location == null) {
            message = mIntent.getStringExtra(LocationPoller.EXTRA_ERROR);
        } else {
            message = "TIMEOUT, lastKnownlocation = " + location.toString();
        }
    } else {
        return location;
    }
    if (message == null)
        message = "Invalid broadcast received!";
    else
        DebugMode.logger(DEBUG_TAG, message);
    return null;
}

From source file:de.htw.ar.treasurehuntar.AbstractArchitectActivity.java

/**
 * Called when the activity is first created.
 *///  ww  w.  jav  a2s  .c o m
@SuppressLint("NewApi")
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // pressing volume up/down should cause music volume changes
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    this.setContentView(this.getContentViewId());
    this.setTitle(this.getActivityTitle());

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    Log.i("architect", "create");

    mGestureDetector = createGestureDetector(this);

    //
    // this enables remote debugging of a WebView on Android 4.4+ when debugging = true in AndroidManifest.xml
    // If you get a compile time error here, ensure to have SDK 19+ used in your ADT/Eclipse.
    // You may even delete this block in case you don't need remote debugging or don't have an Android 4.4+ device in place.
    // Details: https://developers.google.com/chrome-developer-tools/docs/remote-debugging
    //
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
            WebView.setWebContentsDebuggingEnabled(true);
        }
    }

    // set AR-view for life-cycle notifications etc.
    this.architectView = (ArchitectView) this.findViewById(this.getArchitectViewId());

    // pass SDK key if you have one, this one is only valid for this package identifier and must not be used somewhere else
    final ArchitectConfig config = new ArchitectConfig(this.getWikitudeSDKLicenseKey());

    try {
        // first mandatory life-cycle notification
        this.architectView.onCreate(config);
    } catch (RuntimeException rex) {
        this.architectView = null;
        Toast.makeText(getApplicationContext(), "can't create Architect View", Toast.LENGTH_SHORT).show();
        Log.e(this.getClass().getName(), "Exception in ArchitectView.onCreate()", rex);
    }

    // set accuracy listener if implemented, you may e.g. show calibration prompt for compass using this listener
    this.sensorAccuracyListener = this.getSensorAccuracyListener();

    // set urlListener, any calls made in JS like "document.location = 'architectsdk://foo?bar=123'" is forwarded to this listener, use this to interact between JS and native Android activity/fragment
    this.urlListener = this.getUrlListener();

    // register valid urlListener in architectView, ensure this is set before content is loaded to not miss any event
    if (this.urlListener != null && this.architectView != null) {
        this.architectView.registerUrlListener(this.getUrlListener());
    }

    // listener passed over to locationProvider, any location update is handled here
    this.locationListener = new LocationListener() {

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
        }

        @Override
        public void onProviderEnabled(String provider) {
        }

        @Override
        public void onProviderDisabled(String provider) {
        }

        @Override
        public void onLocationChanged(final Location location) {
            // forward location updates fired by LocationProvider to architectView, you can set lat/lon from any location-strategy
            if (location != null) {
                Log.i("location", location.toString());
                // sore last location as member, in case it is needed somewhere (in e.g. your adjusted project)
                AbstractArchitectActivity.this.lastKnownLocation = location;
                if (AbstractArchitectActivity.this.architectView != null) {
                    // check if location has altitude at certain accuracy level & call right architect method (the one with altitude information)
                    if (location.hasAltitude() && location.hasAccuracy() && location.getAccuracy() < 7) {
                        AbstractArchitectActivity.this.architectView.setLocation(location.getLatitude(),
                                location.getLongitude(), location.getAltitude(), location.getAccuracy());
                    } else {
                        AbstractArchitectActivity.this.architectView.setLocation(location.getLatitude(),
                                location.getLongitude(),
                                location.hasAccuracy() ? location.getAccuracy() : 1000);
                    }
                }
            }
        }
    };

    // locationProvider used to fetch user position
    this.locationProvider = new LocationProvider(this, this.locationListener);
}

From source file:net.sylvek.sharemyposition.ShareMyPosition.java

@Override
public void onLocationChanged(final Location location) {
    Log.d(LOG, "location changed: " + location.toString());

    this.location = location;

    final Intent extra = getIntent().getParcelableExtra(EXTRA_INTENT);
    if (extra != null) {
        final Intent b = getIntent();
        boolean isGeocodeAddress = b.getBooleanExtra(ShareMyPosition.PREF_ADDRESS_CHECKED, true);
        boolean isLatLong = b.getBooleanExtra(ShareMyPosition.PREF_LAT_LON_CHECKED, true);
        boolean isUrl = b.getBooleanExtra(ShareMyPosition.PREF_URL_CHECKED, true);
        boolean isGmap = b.getBooleanExtra(ShareMyPosition.PREF_GMAP_CHECKED, false);
        String body = b.getStringExtra(ShareMyPosition.PREF_BODY_DEFAULT);
        final boolean isTracked = b.getBooleanExtra(ShareMyPosition.PREF_TRACK_CHECKED, false);
        final String uuid = UUID.randomUUID().toString();
        double latitude = location.getLatitude();
        double longitude = location.getLongitude();
        share(latitude, longitude, extra, null, body, isGeocodeAddress, isUrl, isGmap, isLatLong, isTracked,
                uuid);// w  ww. j  av a  2s. co  m
    } else {
        showDialog(MAP_DLG);
    }
}