UnifiedNlp/sample/src/org/microg/nlp/api/sample/ThirdSampleService.java
mar-v-in 1f06a663cc Backends should require ACCESS_COARSE_LOCATION permission
Added this to example, as well as various fixes
2014-03-11 19:51:23 +01:00

46 lines
1.1 KiB
Java

package org.microg.nlp.api.sample;
import android.location.Location;
import android.util.Log;
import org.microg.nlp.api.LocationBackendService;
import org.microg.nlp.api.LocationHelper;
import java.util.Random;
public class ThirdSampleService extends LocationBackendService {
private static final String TAG = ThirdSampleService.class.getName();
private Thread regular;
private final Random random = new Random();
@Override
protected void onOpen() {
super.onOpen();
regular = new Thread(new Runnable() {
@Override
public void run() {
synchronized (regular) {
while (!regular.isInterrupted()) {
try {
regular.wait(60000);
} catch (InterruptedException e) {
return;
}
Location location = LocationHelper.create("random", random.nextDouble() * 90, random.nextDouble() * 90, random.nextFloat() * 90);
Log.d(TAG, "Just reported: " + location);
report(location);
}
}
}
});
regular.start();
}
@Override
protected void onClose() {
if (regular != null && regular.isAlive()) {
regular.interrupt();
}
}
}