google map polyline is not working on android version 5.0(lollipop)

前端 未结 2 1553
感动是毒
感动是毒 2020-12-22 05:28

i am trying to draw polyline for googlemap, it is working fine upto android version 4.4(kitkat) but it is not working in android 5.0(lollipop). what to do for working in lol

2条回答
  •  长情又很酷
    2020-12-22 06:03

    Now Again Google has released a new API but they haven't updated the documentation properly.To connect to the API, you need to create an instance of the Google Play services API client.

     mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .addApi(LocationServices.API)
        .build();
    

    Once you have connected to Google Play services and the location services API, you can get the last known location of a user's device. When your app is connected to these you can use the fused location provider's getLastLocation() method to retrieve the device location. To do this you have to implements this interfaces in your Class/Activity

    implements
        ConnectionCallbacks, OnConnectionFailedListener
    

    Then you can found this implemented methods

    @Override
        public void onConnected(Bundle bundle) {
    mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
                    mGoogleApiClient);
            if (mLastLocation != null) {
                mLatitudeText.setText(String.valueOf(mLastLocation.getLatitude()));
                mLongitudeText.setText(String.valueOf(mLastLocation.getLongitude()));
            }
        }
    
        @Override
        public void onConnectionSuspended(int i) {
    
        }
    
        @Override
        public void onConnectionFailed(ConnectionResult connectionResult) {
    
        }
    

    Here is my complete code into this thread . Documentation is here

提交回复
热议问题