简体   繁体   中英

Google map v2 api not tracking user location

For some reason my MapFragment won't show the user location anymore? 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. 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. Any feedback appreciated

Yes, sim card absence could be an issue. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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