Tag: gps

Android GPS获得驾驶汽车的速度

我的android手机如何从GPS获得驾驶汽车的速度? 你能给我一个例子,它可以从GPS获得汽车位置并获得速度吗? 任何建议都是一种帮助。 非常感谢你。

JAVA – GPS RECEPTOR在控制台中发送奇怪/编码的帧

我有一个GPS接收器,它给我发送了NMEA帧。 我的代码检索这些代码,但forms非常奇怪: 我正在使用PuTTY来查看我的受体接收到的NMEA帧,并且没有问题。 编辑 – 这是我正在使用的代码: public class GPSFrame extends Observable implements Runnable { static Thread myThread=null; static BufferedReader br; static BufferedWriter wr; static PrintWriter out; static InputStreamReader isr; static OutputStreamWriter osw; static java.io.RandomAccessFile port; /** CONSTRUCTOR **/ public GPSFrame() { myThread=new Thread(this); } public void start() { try { port=new java.io.RandomAccessFile(“COM5″,”rwd”); port.writeBytes(“\r\n”); port.writeBytes(“c,31,0,0,5\r\n”); port.writeBytes(“T,1000,1\r\n”); […]

网络不可用时防止应用崩溃

我有一个应用程序,它具有从服务启动的前台通知。 该服务每秒调用一个用作GPS连接的类。 GPS类使用NETWORK_PROVIDER和GPS_PROVIDER 。 到目前为止,所有工作都是正确的,除了今天发生的事情。 在某些时候,Android系统显示的消息说“除非你连接到wifi网络或移动网络,否则你将无法访问电子邮件和互联网”。 我不太清楚这条消息,但我有两个按钮:“取消”和“确定”。 从口袋里拿出手机时,我可能会点击某些东西。 在此消息之上是另一条消息,说我的应用程序不幸崩溃了。 所以事件的顺序似乎是这样的:网络禁用(?),应用程序崩溃。 我认为我需要以某种方式处理网络错误,但我现在无能为力,因为我无法从错误中获得太多信息。 有什么想法吗? 谢谢

在设备所有者应用中启用GPS

根据API文档 ,设备所有者应用程序可以通过以下调用修改一些“安全设置”,特别是LOCATION_MODE : devicePolicyManager.setSecureSetting (ComponentName admin, String setting, String value) 由个人资料或设备所有者调用以更新Settings.Secure设置[…] 设备所有者还可以更新以下设置:LOCATION_MODE 根据我的理解,LOCATION_MODE的值是一个int(对于禁用位置,分别为0,仅对于GPS为1,对于省电模式为2,对于高精度为3)。 我的问题是String value参数的类型。 LOCATION_MODE需要一个int,但API需要一个String。 我错过了什么 ?

根据步行速度在2个GPS位置之间插值

问题: 鉴于两个位置: L 1 =(纬度1 ,经度1 ,时间戳1 ) , L 2 =(纬度2 ,经度2 ,时间戳2 ) , 以及可配置但恒定的移动速度: v =每秒1.39米 (例如)。 我们如何在这两个位置之间进行插值以估算用户从L 1到L 2的位置 ? 我一直在寻找这个问题的解决方案,到目前为止我发现,对于小距离(远离极点),可以使用线性插值。 所以,我在维基百科上查找了线性插值 ,发现了这个: // Imprecise method which does not guarantee v = v1 when t = 1, // due to floating-point arithmetic error. float lerp(float v0, float v1, float t) { […]

ECEF到lla(lat,lon,alt)在java中

我查看了网站上的post,但没有发现我的问题…正如头条说我试图从ecef转换为lla。 我正在使用此文档:直接公式中的转换文章 ,而不是迭代公式和此站点进行结果比较: ECEF2LLA 我在java中开发所以我的代码如下: public static final double a = 6378137; public static final double f = 1/298.257223563; public static final double b = a*(1-f); public static final double e = Math.sqrt((Math.pow(a, 2)-Math.pow(b, 2))/Math.pow(a, 2)); public static final double e2 = Math.sqrt((Math.pow(a, 2)-Math.pow(b, 2))/Math.pow(b, 2)); public static double[] ecef2lla(double x , double y , […]

位置管理器无法在Android 4.0.2模拟器中运行

我在我的应用程序中使用Location Manager进行GPS跟踪。 在Android 2.2,2.3.3模拟器和设备中使用时,应用程序返回apt位置。 但是,奇怪的是我在模拟器4.0.2中测试了应用程序。 它返回强制关闭错误,如05-28 15:13:46.584: E/AndroidRuntime(4458): at com.package.TestRun.registerLocationListeners(TestRun.java:191)在logcat中的 05-28 15:13:46.584: E/AndroidRuntime(4458): at com.package.TestRun.registerLocationListeners(TestRun.java:191) 。 我已经实现了如下代码: LocationManager lm; LocationManager lmNet; private void registerLocationListeners() { lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (myGPSLocationListener == null || mynetworkprovider == null) { createLocationListeners(); } lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER ,0,0,mynetworkprovider); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER ,60000,0,myGPSLocationListener); } private void createLocationListeners() { mynetworkprovider = new LocationListener() { public […]

如何在Java中将GPS元数据添加到TIFF?

我正在尝试将GPS数据添加到我用Java创建的TIFF文件中。 我正在使用JAI-ImageIO库,虽然如果有更好的库来同时执行G​​PS元数据和自定义元数据,我愿意研究它。 我试图直接将GPS元数据添加到节点,但它似乎剥离了GPS IDF标签。 我试图将GPS IFD添加到TIFFIFD对象(来自TIFFIMageMetadata对象),但这似乎并没有正确保存数据。 基本上,我正在努力让它正确地保存GPS数据,并试图弄清楚如何在那里获取数据。 在互联网上搜索的时间几乎没有产生任何教程或帮助,我没有看到任何有用的Stack Overflow,但我的搜索能力可能缺乏。 我尝试通过直接操作元数据节点来完成一些代码: RenderedImage img = generateImageSomehow(); File writeTarget = new File(“blah.tiff”); //Get the image writer Iterator writers = ImageIO.getImageWritersByFormatName(“tiff”); ImageTypeSpecifier specifier = new ImageTypeSpecifier(renderedImage); ImageWriter writer = writers.next(); //Get the metadata IIOMetadata metadata = writer.getDefaultImageMetadata(specifier, writers.getDefaultWriteParam()); Node root = metadata.getAsTree(FileConstants.TIFF_METADATA_FORMAT); Node ifd = root.getFirstChild(); //Create a new […]

获取Android Studio应用中的当前位置

我正在开发我的第一个Android应用程序,它应该获取Android设备的经度和经度 ,并通过Web服务将其发送到模板文档。 我按照http://developer.android.com/training/location/retrieve-current.html获取位置的指南。 这是我的.java类的代码: import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.location.Location; import android.location.LocationManager; import android.os.Bundle; import android.provider.Settings; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.EditText; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationServices; public class GetLocation extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private GoogleApiClient mGoogleApiClient; EditText textLat; EditText textLong; EditText lat; EditText lon; protected void onCreate(Bundle […]

GPS应用程序的距离

可能重复: 如何在Android上通过GPS跟踪距离? 我设计了一个GPS应用程序,它很好地说明了我的位置。 但现在我想要包含更多function。 我将如何在那里制作一个半径? 周边地区为5或6公里! 我怎么能提到那个地方和我的地方之间的距离?