Android:通过蓝牙GPS访问NMEA数据
我需要从连接的蓝牙GPS接收器访问NMEA字符串。注意:这适用于cordova应用程序Android:通过蓝牙GPS访问NMEA数据,android,cordova,bluetooth,gps,nmea,Android,Cordova,Bluetooth,Gps,Nmea,我需要从连接的蓝牙GPS接收器访问NMEA字符串。注意:这适用于cordova应用程序 我已成功将接收器连接到Android设备 使用Android应用程序蓝牙GPS 通过允许模拟GPS提供商,我已经成功地在我的应用程序中使用了接收器 我可以成功地从设备的内部GPS获取NMEA数据,但当我启用模拟GPS提供程序时,NmeaListener停止启动 环境: 三星SM-T700 安卓4.4.2 科尔多瓦3.3.1 接收器箭头100 代码 权限 package org.apache.cor
- 我已成功将接收器连接到Android设备 使用Android应用程序蓝牙GPS
- 通过允许模拟GPS提供商,我已经成功地在我的应用程序中使用了接收器
- 我可以成功地从设备的内部GPS获取NMEA数据,但当我启用模拟GPS提供程序时,NmeaListener停止启动
- 三星SM-T700
- 安卓4.4.2
- 科尔多瓦3.3.1
- 接收器箭头100
package org.apache.cordova.nmea;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import android.content.Context;
import android.location.LocationManager;
import android.location.GpsStatus.NmeaListener;
import android.util.Log;
public class Nmea extends CordovaPlugin implements NmeaListener{
private LocationManager locationManager;
private CallbackContext savedCallbackContext;
/**
* Executes the request and returns PluginResult.
*
* @param action The action to execute.
* @param args JSONArry of arguments for the plugin.
* @param callbackContext The callback id used when calling back into JavaScript.
* @return True if the action was valid, or false if not.
*/
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
this.savedCallbackContext = callbackContext;
if (this.locationManager == null) {
this.locationManager = (LocationManager) this.cordova.getActivity().getSystemService(Context.LOCATION_SERVICE);
}
if (action.equals("setNmeaListener")) {
Log.w("NMEA", "setNmeaListerer fired");
this.locationManager.addNmeaListener(this);
}
return true;
}
public void onNmeaReceived(long timestamp, String nmea) {
Log.w("Nmea", nmea);
this.win(nmea);
}
private void win(String message) {
// Success return object
PluginResult result = new PluginResult(PluginResult.Status.OK, message);
result.setKeepCallback(true);
this.savedCallbackContext.sendPluginResult(result);
}
}
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />