This project provides the Android SDK and example source code that XGPS150/XGPS160/XGPS500/DashPro(XGPS360) exchanges data with Android device via Bluetooth connection.
Add it to your build.gradle with:
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
and:
dependencies {
implementation 'com.github.dualav:XGPS-SDK-Android:2.0.0-beta'
}
public class MainActivity extends AppCompatActivity implements XGPSListener {
...
XGPSManager xgpsManager;
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
xgpsManager = new XGPSManager(this, this);
}
@Override
protected void onDestroy() {
...
xgpsManager.onDestroy();
}
// handling listener
@Override
void updateLocationInfo() {
...
latitude.setText(xgpsManager.getLatitude(XGPSManager.MODE_POSITION_DEGREE));
longitude.setText(xgpsManager.getLongitude(XGPSManager.MODE_POSITION_DEGREE));
altitude.setText(xgpsManager.getAltitude(Constants.MODE_ALTITUDE_FEET));
heading.setText(xgpsManager.getHeadingString());
speed.setText(xgpsManager.getSpeed(Constants.MODE_SPEED_KPH));
utc.setText(xgpsManager.getUTC());
}
@Override
void updateSatellitesInfo(int systemId) {
// Because of frequent calls, updating the UI every time can degrade app performance. It is recommended that the UI be updated only when necessary.
String numberOfSatellites = "";
HashMap<Integer, SatellitesInfo> satellitesMap = (HashMap<Integer, SatellitesInfo>) xgpsManager.getSatellitesInfoMap().getAll(systemId);
Iterator<Integer> it = satellitesMap.keySet().iterator();
while (it.hasNext()) {
Integer key = it.next();
if (numberOfSatellites.length() > 0) {
numberOfSatellites += ", ";
}
numberOfSatellites += key;
}
String avgSNR = String.valueOf(xgpsManager.getAverageSNRInUse());
String inUseList = String.join(", ", xgpsManager.getSatellitesInUse(systemId));
...
}
...
will be updated