我正在开发一个使用Location类发送模拟位置数据的应用程序。还发送一些参数,例如HDOP,VDOP,PDOP,捆绑式卫星发射,并且发送完美。但是,如何在另一个应用程序中获取那些捆绑数据。我只得到那些使用位置默认方法(例如setLatitude,SetLongitude等)添加的数据,而不是那些捆绑数据。
Location mockLocation = new Location(LocationManager.GPS_PROVIDER);
mockLocation.setLatitude(lat);
mockLocation.setLongitude(lon);
//mockLocation.setAltitude(0);
mockLocation.setAltitude(Double.parseDouble(elev)); //in meters// Height msl
mockLocation.setAccuracy(Float.parseFloat(accuracy)); //in meters// HDOP
mockLocation.setTime(System.currentTimeMillis());
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
mockLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
// Elapsed time can also be set using
// mockLocation.setElapsedRealtimeNanos(System.nanoTime());
// Elapsed time can be disregarded using
// mockLocation.makeComplete();
}
Bundle bundle = new Bundle();
bundle.putInt("satellites",(int)PGGConstant.total_satellite_used);
bundle.putFloat("pdop",Float.parseFloat(PGGConstant.pdop));
bundle.putFloat("hdop",Float.parseFloat(PGGConstant.hdop));
bundle.putFloat("vdop",Float.parseFloat(PGGConstant.vdop));
bundle.putFloat("diffAge", Float.parseFloat(PGGConstant.diffeAge));
bundle.putInt("diffStatus",Integer.parseInt(PGGConstant.fixType_digit));
bundle.putInt("diffID",(int)PGGConstant.diffID);
bundle.putFloat("3drms",Float.parseFloat(PGGConstant.threeDAccuracy));
bundle.putFloat("vrms",Float.parseFloat(PGGConstant.vrms));
bundle.putFloat("hrms",Float.parseFloat(PGGConstant.hrms));
bundle.putFloat("mslHeight",Float.parseFloat(PGGConstant.heightMSL.split(" ")[0]));
bundle.putFloat("ondulation",Float.parseFloat(PGGConstant.geoidSeparation.split(" ")[0]));
bundle.putString("receiverModel",PGGConstant.connecteddeviceName);
bundle.putString("mockProvider","xyz");
bundle.putFloat("utcTime", Float.parseFloat(PGGConstant.UTC_Time_Stamp));
mockLocation.setExtras(bundle);