简体   繁体   English

谷歌地图v2 api不跟踪用户位置

[英]Google map v2 api not tracking user location

For some reason my MapFragment won't show the user location anymore? 出于某种原因,我的MapFragment将不再显示用户位置? Map tiles are still displayed but it's not displaying current location?? 地图图块仍然显示但是它没有显示当前位置?

         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);


            }

This is my basic MapFragment which normally worked until i started testing on another Android device which uses the same android version only difference is theres no SIM card in the device. 这是我的基本MapFragment ,通常工作,直到我开始测试另一个Android设备使用相同的Android版本只有区别是设备中没有SIM卡。 Does that make a difference?? 这有什么区别吗??

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> 

I have no idea how the api has stopped working. 我不知道api是如何停止工作的。 Any feedback appreciated 任何反馈意见

Yes, sim card absence could be an issue. 是的,SIM卡缺席可能是一个问题。 I have the same trouble wasn't able to get location without sim card (no SIM - no network location provider), because GPS location provider couldn't determine location indoors. 我有同样的麻烦是没有SIM卡无法获得位置(没有SIM - 没有网络位置提供商),因为GPS位置提供商无法确定室内位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM