this sdk support XGPS150 / XGPS160 / XGPS500
Switch branches/tags
Nothing to show
Clone or download



This project provides the Android SDK and example source code that XGPS150/XGPS160/XGPS500 exchanges data with Android device via Bluetooth connection.



  • OS : Above Android 4.3 (API Level 18)
  • Bluetooth : activate
  • External Bletooth GPS Device : XGPS150 / XGPS160 / XGPS500


  • Bluetooth connection with XGPS Series via SPP communication
  • parsing NMEA sentence
  • parsing XGPS custom command


  • SDK include the following permission
    <!-- bluetooth communication -->
    <uses-permission android:name="android.permission.BLUETOOTH" />     
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <!-- in order to replace the android's internal GPS location -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
  • If you use MockLocation and Android OS is above 6.0, you should do check self permission.
protected void onCreate(Bundle savedInstanceState) {
    // user accept the location permission request at runtime.
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int hasWriteContactsPermission = checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION);
        if (hasWriteContactsPermission != PackageManager.PERMISSION_GRANTED) {
            requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
  • for the result from requesting location permissions
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    switch(requestCode) {
            if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
            super.onRequestPermissionsResult(requestCode, permissions, grantResults);


for using the XGPS SDK in your Android Studio, follow the steps below. (you can choose one method)

method 1 : adding aar file directly

  1. copy a xgpsManager.aar to your project. (ex. myproject/library/xgpsManager.aar)
  2. open the application's 'build.gradle'.
  3. adding repositories and dependencies like below.
repositories {
    flatDir {
        dirs 'library/'     // aar file path

dependencies {
    compile(name: 'xgpsManager', ext: 'aar')

method 2 : using dialog command in Android studio

  1. File > New > New Module > Import .JAR/.AAR Package
  2. File name : as xgpsManager.aar, Subproject name: as xgpsManager
  3. Open Project structure (using Ctrl+Enter/⌘+Enter)
  4. dependency > + > Module dependency
  5. choose xgpsManager' module



Public constructors Parameters
XGPSManager Context
XGPSListener The callback that the result receive. This value may be null.
Public methods Return Parameters
onResume void retry to start bluetooth connection thread
isConnected boolean returns bluetooth connection status.
setListener void XGPSListener The callback that the result receive. This value may be null.
setMockEnable void enable true is MockLocationProvider as gps provider, false is disable
sendCommandToDevice void cmd custom command for xgps. you can see the Constants list.
buffer byte buffer to transfer to xgps devices.
bufLen buffer's length
getBatteryLevel float get battery level. min value is 0.0, max value is 1.0
isCharging boolean return battery is charging or not.
getFirmwareVersion String return firmware version as String
getLatitude String mode latitude as String. mode can be MODE_POSITION_DMS, MODE_POSITION_DM, MODE_POSITION_DEGREE
getLatitude float latitude as float in degree
getLongitude String mode longitude as String. mode can be MODE_POSITION_DMS, MODE_POSITION_DM, MODE_POSITION_DEGREE
getLongitude float longitude as float in degree
getAltitude String mode altitude as String. mode can be MODE_ALTITUDE_FEET, MODE_ALTITUDE_METER
getAltitude float altitude as float in meter
getUTC String
getSpeed String mode speed as String. mode can be MODE_SPEED_KNOTS, MODE_SPEED_KPH, MODE_SPEED_MPH
getSpeed float speed as float in knots
getHeadingString String heading as String in degree
getHeading float heading as float
getHDOP int
getVDOP int
getPDOP int
getSatellitesMap HashMap GPS satellites information. see the SatellitesInfo class
getGlonassSatellitesMap HashMap GLONASS satellites information. see the SatellitesInfo class. / not supported XGPS150
getFixType int return TYPE_NO_FIX, TYPE_2D_FIX, TYPE_3D_FIX
getAvailableDevices ArrayList get bonded XGPS series bluetooth devices
onDestroy void


Public methods
abstract void connecting(BluetoothDevice device) Called when bluetooth try to connect.
abstract void connected(boolean isConnect, int error) Called when bluetooth connection changed.
abstract void updateLocationInfo() Called when get location information from device
abstract void updateSatellitesInfo() Called when get satellites information from device.
abstract void updateSettings(boolean positionEnable, boolean overWrite) Called when get settings changed.
abstract void getLogListComplete(ArrayList logList) Called when get log list complete. / not supported XGPS150
abstract void getLogDetailProgress(int bulkCount) Called when get detail log download progress. / not supported XGPS150
abstract void getLogDetailComplete(ArrayList logBulkList) Called when get detail log download complete. / not supported XGPS150
abstract void throwException(Exception e) Called when occur exception.

Mock Location

In order to replace internal GPS location to external XGPS device, you can use XGPSManager.setMockEnable method. But in above Android 6.0, you should change the mock provider permissions in developer option. Please go to the developer option > Select mock location app > select your app as provider.

  • Please reference the xgpsSample project to see detail.