2013-05-10 71 views
0

由于某种原因,我的MapFragment不再显示用户位置?地图砖仍然显示,但它不显示当前位置?Google地图v2 api未跟踪用户位置

  public class MyTask extends AsyncTask<Void, Void, Void>{ 

       protected void onPreExecute() { 

        map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)) 
          .getMap(); 
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(place, 4000)); 
        map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null); 
        map.setMyLocationEnabled(true); 
        map.getUiSettings().setZoomControlsEnabled(true); 
        map.getUiSettings().setMyLocationButtonEnabled(true); 
        map.setTrafficEnabled(true); 
        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 


      } 

这是我的基本MapFragment其工作正常,直到我使用相同的Android版本唯一的区别是在孤单的设备没有SIM卡的另一个Android设备上开始测试。这有什么区别吗??

Manifest-

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example" 
    android:versionCode="1" 
    android:versionName="1.0" 
    android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:resizeable="true" 
    android:anyDensity="true" 
    android:theme="@android:style/Theme.NoTitleBar" > 

    <uses-sdk 
     android:minSdkVersion="15" 
     android:targetSdkVersion="17" /> 

    <permission 
     android:name="com.example.permission.MAPS_RECEIVE" 
     android:protectionLevel="signature" /> 

    <uses-feature 
     android:glEsVersion="0x00020000" 
     android:required="true" /> 

    <uses-permission android:name="com.example.permission.MAPS_RECEIVE" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 
    <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_NETWORK_STATE" /> 


     <application 
      android:icon="@drawable/applogo12" 
      android:label="@string/app_name" 
      android:theme="@style/CustomTheme"> 


     <activity 
      android:name=".SplashActivity" 
      android:screenOrientation="portrait"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity android:name=".HomeActivity" android:screenOrientation="portrait"></activity> 




     <meta-data 
      android:name="com.google.android.maps.v2.API_KEY" 
      android:value="-----" /> 
    </application> 
</manifest> 

我不知道该API是如何停止工作。 任何反馈赞赏

+0

基于提供的代码,我很惊讶它曾经显示过用户的位置。你在哪里'LocationListener'?您在哪里/如何为用户显示“标记”?刚刚获得一个'LocationManager'不会做任何事情。 – Rarw 2013-05-10 13:04:50

+0

尝试使用FakeGPS位置https://play.google.com/store/apps/details?id=com.lexa.fakegps如果有效,那么问题在于室内没有GPS。 – 2013-05-10 13:22:53

+0

感谢回复@Rarw – PropK 2013-05-10 13:24:20

回答

2

是的,SIM卡缺席可能是一个问题。我有同样的麻烦是无法获得位置没有SIM卡(没有SIM - 没有网络位置提供商),因为GPS位置提供商无法确定室内位置。

+0

Thanks @Rodion Altshuler – PropK 2013-05-10 13:24:02