0

What i do: i use Nokia Here-maps wrapper v2 to display a map with one custom marker and the user's position. Then i use PolyLines to draw direction between those 2 points. All works fine with Google Play Services but on Nokia X i can't get user location, call to setMyLocationEnabled on the map object throws :

java.lang.IllegalArgumentException: provider doesn't exisit: null at android.os.Parcel.readException(Parcel.java:1435) at android.os.Parcel.readException(Parcel.java:1385) at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:540) at android.location.LocationManager.requestLocationUpdates(LocationManager.java:836) at android.location.LocationManager.requestLocationUpdates(LocationManager.java:430) at com.nokia.maps.DeviceLocation.M(DeviceLocation.java:380) at com.nokia.maps.DeviceLocation.start(DeviceLocation.java:107) at com.nokia.maps.PositioningManager.start(PositioningManager.java:171) at com.nokia.android.gms.maps.GoogleMap.setPositionManagerEnabled(GoogleMap.java:1442) at com.nokia.android.gms.maps.GoogleMap.setMyLocationEnabled(GoogleMap.java:1420) at com.nokia.android.gms.maps.GoogleMap.onInitializationComplete(GoogleMap.java:696) at com.nokia.android.gms.maps.MapView.attachMapToMapViewSetup(MapView.java:293) at com.nokia.android.gms.maps.MapView.access$19(MapView.java:271) at com.nokia.android.gms.maps.MapView$4.onFactoryInitializationCompleted(MapView.java:263) at com.nokia.maps.MapFactory$2.run(MapFactory.java:455)

Manifest

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<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-feature android:name="android.hardware.location.gps" android:required="false" />
<uses-feature android:name="android.hardware.location" android:required="false" />
<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>

<application
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:hardwareAccelerated="true" >
    <uses-library android:name="com.here.android" android:required="false" />
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="MY_GOOGLE_APIV2_KEY"/>
    <meta-data android:name="com.here.android.maps.appid" android:value="MY_HERE_APPID" />
    <meta-data android:name="com.here.android.maps.apptoken" android:value="MY_HERE_TOKEN" />

    <activity
        android:name=".MapsFragmentActivity"
        android:label="@string/title_activity_maps" >
    </activity>
</application>

Map fragment layout

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/map"
    android:name="com.nokia.android.gms.maps.SupportMapFragment" />

Map fragment activity class

public class StadiumsMapsFragmentActivity extends FragmentActivity {
    private MapsFragmentLegacy mMapFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mapactivity);
        setUpMapIfNeeded();
    }

    private void setUpMapIfNeeded() {
        try {
            if(mMapFragment == null) {
                if (MyWrapper.hasHere(context)) {
                    mMapFragment = new MapsFragmentHere();
                } else {
                    mMapFragment = new MapsFragmentGoogle();
                }
                FragmentManager fragmentManager = getSupportFragmentManager();
                fragmentManager.beginTransaction().add(R.id.map_container, mMapFragment).commit();
            }
        }
        catch(Exception e){
            if(DEBUG)e.printStackTrace();
        }
    }
}

MapsFragmentHere class

import com.nokia.android.gms.maps.CameraUpdateFactory;
import com.nokia.android.gms.maps.GoogleMap;
import com.nokia.android.gms.maps.SupportMapFragment;
import com.nokia.android.gms.maps.model.BitmapDescriptorFactory;
import com.nokia.android.gms.maps.model.LatLng;
import com.nokia.android.gms.maps.model.MarkerOptions;
import com.nokia.android.gms.maps.model.PolylineOptions;

public class MapsFragmentHere extends MapsFragmentLegacy {
    private GoogleMap mMap;
    private LatLng mLatLng;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        FRAGMENT_LAYOUT = R.layout.hmaps;
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        SupportMapFragment mapFragment = (SupportMapFragment) getFragmentManager().findFragmentById(FRAGMENT_ID);
        mMap = mapFragment.getMap();
        setUpMap();
    }

    private GoogleMap.OnMyLocationChangeListener myLocationChangeListener = new GoogleMap.OnMyLocationChangeListener() {
        @Override
        public void onMyLocationChange(Location location) {
                LatLng origin = new LatLng(location.getLatitude(), location.getLongitude());
                // Draw direction if needed
        }
    };

    private void setUpMap() {
        if(mMap != null) {
            mLatLng = new LatLng(LATITUDE, LONGITUDE);
            mMap.setMyLocationEnabled(true);
            mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16));
            mMap.addMarker(new MarkerOptions()
                .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker))
                .title("title")
                .snippet("")
                .position(mLatLng));
            mMap.setOnMyLocationChangeListener(myLocationChangeListener);
        }
    }
}

MapsFragmentLegacy class

public class MapsFragmentLegacy extends Fragment {
    protected static int FRAGMENT_LAYOUT = R.layout.maps;
    protected static final int FRAGMENT_ID = R.id.map;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(FRAGMENT_LAYOUT, container, false);
    }
}

Map is displayed correctly with camera position, initial zoom, working zoom controls and custom marker. Any help will be appreciated :)

BOSSoNe
  • 11
  • 1
  • 4
  • if the same implementation works with Google Maps enabled device, and fails when uisng the wrapper, and you can pinpoint the error, then it might be a bug, which you should report to developer.nokia.com – Dr.Jukka Jul 12 '14 at 18:13
  • Anyway, before submitting the bug report, do try using a real application ID & token values in the app, and do check that you followed all steps in the docs, as well as that you are using the latest release of the wrapper library by updating your SDK with SDK manager – Dr.Jukka Jul 12 '14 at 18:14
  • LoL you are kiding me ? You really think that i test my code with no valid appid and token ? i've replace values here as i don't want to give my keys to the world. – BOSSoNe Jul 13 '14 at 22:47
  • So, now on my problem. Why do you talk about bug-repport? Yes the wrapper is working with Google Play Services and alos with Nokia Here, but with Here there's a problem with setMyLocationEnabled. – BOSSoNe Jul 13 '14 at 22:50

0 Answers0