Class GPS


  • public class GPS
    extends ApiBindBase
    This class provides GPS related APIs which are only for the cradle with UBlox GPS chip.

    Sample Code:

      package com.mitac.api;
    
      import android.app.Activity;
      import android.os.Bundle;
    
      import com.mitac.api.libs.GPS;
      import com.mitac.api.libs.ServiceStatusCallback;
    
      public class MainActivity extends Activity {
          private GPS mGPS;
    
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
    
              // when creating the instance the service is auto binding
              // register a callback to listen service status
              mGPS = new GPS(getApplicationContext(), new ServiceStatusCallback() {
                  @Override
                  public void ready() {
                      startTest();
                  }
              });
              mGPS.bindService();
          }
    
          private void startTest() {
              if (mGPS != null) {
                  if (!mGPS.enableDr(0)) { // disable DR
                      // remote fail to do the operation
                  }
              }
          }
    
          @Override
          protected void onStop() {
              super.onStop();
    
              if (mGPS != null) {
                  mGPS.unbindService();
              }
          }
      }
     
    • Constructor Detail

      • GPS

        public GPS​(android.content.Context context)
        This constructor will not bind the service automatically. Please call bindService() at least once before using APIs.
        Parameters:
        context - better to use Context.getApplicationContext() to prevent memory leaks
        Throws:
        java.lang.IllegalArgumentException - if context is null.
      • GPS

        public GPS​(android.content.Context context,
                   ServiceStatusCallback callback)
        This constructor will bind the service automatically.
        Parameters:
        context - better to use Context.getApplicationContext() to prevent memory leaks
        callback - used to get the notification when service is ready.
        Throws:
        java.lang.IllegalArgumentException - if context or callback is null.
        See Also:
        ServiceStatusCallback
    • Method Detail

      • sendCommand

        public boolean sendCommand​(byte[] command)
        Parameters:
        command - byte array
        Returns:
        true :success ; false:failed
      • getDrStatus

        public int getDrStatus()
        Returns:
        1 DR ;0 no DR ;-1 ERROR;
      • getCurrentGpsSource

        public int getCurrentGpsSource()
        Returns:
        1 ublox ; 0 qcom ; -1 error;
      • enableDr

        public boolean enableDr​(int enable)
        Parameters:
        enable - 1 or 0
        Returns:
        true :success ; false:failed
      • setCheckerThreshold

        public boolean setCheckerThreshold​(int mode,
                                           double threshold)
        Parameters:
        mode - ?
        threshold - ?
        Returns:
        true :success ; false:failed
      • setCheckerMode

        public boolean setCheckerMode​(int mode,
                                      int value)
        Parameters:
        mode - ?
        value - ?
        Returns:
        true :success ; false:failed
      • isServiceReady

        public boolean isServiceReady()
        Check if service is ready.
        Returns:
        true if ready; false otherwise.