Package com.mitac.api.libs
Class GPS
- java.lang.Object
-
- com.mitac.api.libs.ApiBindBase
-
- com.mitac.api.libs.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 Summary
Constructors Constructor Description GPS(android.content.Context context)
This constructor will not bind the service automatically.GPS(android.content.Context context, ServiceStatusCallback callback)
This constructor will bind the service automatically.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bindService()
bind serviceboolean
enableDr(int enable)
int
getCurrentGpsSource()
int
getDrStatus()
boolean
isServiceReady()
Check if service is ready.boolean
sendCommand(byte[] command)
boolean
setCheckerMode(int mode, int value)
boolean
setCheckerThreshold(int mode, double threshold)
void
unbindService()
unbind service
-
-
-
Constructor Detail
-
GPS
public GPS(android.content.Context context)
This constructor will not bind the service automatically. Please callbindService()
at least once before using APIs.- Parameters:
context
- better to useContext.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 useContext.getApplicationContext()
to prevent memory leakscallback
- used to get the notification when service is ready.- Throws:
java.lang.IllegalArgumentException
- if context or callback is null.- See Also:
ServiceStatusCallback
-
-
Method Detail
-
bindService
public void bindService()
Description copied from class:ApiBindBase
bind service- Specified by:
bindService
in classApiBindBase
-
unbindService
public void unbindService()
Description copied from class:ApiBindBase
unbind service- Specified by:
unbindService
in classApiBindBase
-
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.
-
-