You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.2 KiB
86 lines
2.2 KiB
package de.gulpe.sposmroute;
|
|
|
|
import android.app.NativeActivity;
|
|
import android.location.Location;
|
|
import android.location.LocationListener;
|
|
import android.location.LocationManager;
|
|
import android.os.Bundle;
|
|
import android.util.Log;
|
|
import android.content.Context;
|
|
import android.location.GpsStatus.NmeaListener;
|
|
import android.view.WindowManager;
|
|
import android.view.ViewGroup.LayoutParams;
|
|
|
|
public class spOSMrNActivity extends NativeActivity {
|
|
private static final String TAG = "spOSMroute Java";
|
|
spOSMrNActivity _activity;
|
|
String gpsline;
|
|
String nmealine;
|
|
boolean started = false;
|
|
private LocationManager mLocMan;
|
|
private LocationListener mLocListener;
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
mLocMan = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
|
mLocListener = new MyLocationListener();
|
|
mLocMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mLocListener);
|
|
mLocMan.addNmeaListener(new NmeaListener() {
|
|
public void onNmeaReceived(long timestamp, String nmea) {
|
|
if (started) {
|
|
nmealine = nmealine + nmea;
|
|
}
|
|
// Log.i(TAG, "GPSData (cur nmea:"+nmealine+")");
|
|
}
|
|
});
|
|
|
|
super.onCreate(savedInstanceState);
|
|
_activity = this;
|
|
}
|
|
|
|
|
|
private class MyLocationListener implements LocationListener {
|
|
@Override
|
|
public void onLocationChanged(Location loc) {
|
|
}
|
|
|
|
@Override
|
|
public void onProviderDisabled(String provider) {
|
|
}
|
|
|
|
@Override
|
|
public void onProviderEnabled(String provider) {
|
|
}
|
|
|
|
@Override
|
|
public void onStatusChanged(String provider, int status, Bundle extras) {
|
|
}
|
|
}
|
|
|
|
// get gps data fill one line into gpsline
|
|
public void GPSDataGetLine() {
|
|
// Log.i(TAG, "GPSDataGetLine called sending:'"+nmealine+"'");
|
|
gpsline = nmealine;
|
|
nmealine = "";
|
|
}
|
|
|
|
// start gps part
|
|
public void GPSDataStart() {
|
|
Log.i(TAG, "GPSDataStart called");
|
|
started = true;
|
|
}
|
|
|
|
// stop gps part
|
|
public void GPSDataStop() {
|
|
Log.i(TAG, "GPSDataStop called");
|
|
started = false;
|
|
}
|
|
|
|
// Do some cleanup
|
|
@Override
|
|
public void onDestroy() {
|
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
super.onDestroy();
|
|
}
|
|
}
|