GPS on emulator doesn't get the geo fix - Android

匿名 (未验证) 提交于 2019-12-03 01:41:02

问题:

I'm developing an application for the android OS, I'm just starting, but I can't get the GPS on the emulator to work. I've read on the internet that you need to send a geo fix to the emulator in order to enable the gps locationProvider. I'm both using the DDMS and telnet to try to send it, but logcat never tells me the it recived a new fix, and my apolication still sees the gps as disabled

here's my code

package eu.mauriziopz.gps;  import java.util.Iterator; import java.util.List;  import android.app.Activity; import android.content.Context; import android.location.LocationManager; import android.os.Bundle; import android.util.Log;  public class ggps extends Activity {     /** Called when the activity is first created. */     @Override     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.main);          LocationManager l =(LocationManager) getSystemService(Context.LOCATION_SERVICE);         List li = l.getAllProviders();         for (Iterator iterator = li.iterator(); iterator.hasNext();) {             String string =  iterator.next();             Log.d("gps", string);         }         if (l.getLastKnownLocation("gps")==null)             Log.d("gps", "null");        } } 

I've read that the DDMS may not work properly on a non english OS, but telnet should work!

update: the gps is enabled in the settings

回答1:

Turns out, that since I was developing for Android 1.5 (and not Google API 1.5) the map (and looks like other features) were disabled. As soon as I changed the target platform, my error disappeared.

btw thanks all



回答2:

To test if the geofix is working you could use the Google Maps app with "My Location"



回答3:

Make sure that the gps in enabled in the settings. If still the problem persists, you just go to the application named Navigation in the main menu, run it and exit. Now try your application. You can enable location controls under emulator control in DDMS perspective by selecting a particular device. without selecting a device it will not work



回答4:

I supose is fixed yet, but in the code you should use as provider a string returned by the LocationManager service, instead of "gps" as you put in l.getLastKnownLocation("gps").



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!