Here Maps Android SDK call to PositioningManager start method returns false

前端 未结 2 2035
面向向阳花
面向向阳花 2021-01-23 12:49

I\'ve read this question and tried its answer and it doesn\'t work for me.

I made a very simple test application, here\'s the manifest:



        
相关标签:
2条回答
  • 2021-01-23 13:04

    Looks like you solved his problem with the help of here-maps-android-sdk-call-to-positioningmanager-start-method-returns-false But there is still issue with problems-using-here-api-to-get-my-position-wifi-updated

    To properly init map engine, it is required to grand the following permissions:

    Manifest.permission.ACCESS_NETWORK_STATE
    Manifest.permission.ACCESS_WIFI_STATE
    Manifest.permission.INTERNET
    

    Missing to grant one of them will lead to MISSING_PERMISSIONS error in logs (which I saw on first SO link). Regarding positioning, it's recommended to grant both permissions - ACCESS_FINE_LOCATION (Allows an app to access precise location) and ACCESS_COARSE_LOCATION (Allows an app to access approximate location).

    Please have a look at these advices, and let us know whether the issue was solved. Thank you!

    0 讨论(0)
  • 2021-01-23 13:07

    On advice from @HERE Developer Support, I have got this example working = the code is changed as follows:

    private void setUpPositioning() {
        // new lines from HERE
        MapEngine.getInstance().init(this, new OnEngineInitListener() {
            @Override
            public void onEngineInitializationCompleted(Error error) {
                if (error == Error.NONE) {
                    Log.i("Position", "correctly started map engine");
                } else {
                    Log.i("Position", "Problem setting up map engine: " + error);
                }
            }
        });
        //end of lines from HERE
        PositioningManager pm = PositioningManager.getInstance();
        PositioningManager.LocationStatus  ls = pm.getLocationStatus(PositioningManager.LocationMethod.GPS_NETWORK);
        Log.i("Position", "Setting up positioning");
        if (ls ==  PositioningManager.LocationStatus.AVAILABLE) {
            Log.i("Position", "Positioning is available");
        } else {
            Log.w("Position", "Positioning not available right now: " + ls.toString());
        }
        boolean ret = pm.start(PositioningManager.LocationMethod.GPS_NETWORK);
        Log.i("Position", "Positioning start returns " + ret);
        timerTickEveryMinute();
    }
    

    Now I receive Logs like this:

    2019-01-27 12:02:51.716 1790-1790/com.company.app I/Position: Setting up positioning
    2019-01-27 12:02:51.716 1790-1790/com.company.app W/Position: Positioning not available right now: TEMPORARILY_UNAVAILABLE
    2019-01-27 12:02:51.745 1790-1790/com.company.app I/Position: Positioning start returns true
    2019-01-27 12:02:51.760 1790-1790/com.company.app I/Position: Problem setting up map engine: MISSING_PERMISSION
    2019-01-27 12:02:56.749 1790-2674/com.company.app I/Position: Location: Latitude = 31.8051461, Longitude = 35.092536
    2019-01-27 12:02:56.750 1790-2674/com.company.app I/Position: Accuracy = 19.71, 19.71
    

    I'm not sure what permission I'm missing, but it doesn't seem to matter since the code now works... unfortunately, it is not working in my more complex app :-( . The more complex app is mentioned here

    0 讨论(0)
提交回复
热议问题