Skip to content

Instantly share code, notes, and snippets.

@apascual
apascual / gist:d3a72061539da497d03cf42265c627f2
Created August 11, 2017 07:31 — forked from phpmaps/gist:5699732
Android polling example which gets triggered every 10 seconds.
protected void getLocationPeriodically() {
mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
Location l = (Location) msg.obj;
Toast.makeText(getApplicationContext(), "Latitude: " + String.valueOf(l.getLatitude()) + " Longitude: " + String.valueOf(l.getLongitude()),
Toast.LENGTH_LONG).show();
}
};
new Thread(new Runnable() {