简体   繁体   中英

Google Play services version issue

I have a problem - i'm using Google Maps v2 in my application. To use it i obvious added Google Play services lib to my project.

Everything is working great on my device but crash on others with older Android, for example, my app work on 4.3 but don't work on 4.0.3.

I have figured out the problem - on these devices Google Play services are not last version. In Android SDK Tools i have Google Play services revision 13. When i have installed update of Google Play services my application works fine.

So what the best way to solve this problem? May be i need to use some older methods to get map from MapFragment? Here's my code.

public class CustomMapFragment extends MapFragment {
    private GoogleMap mMap;

    public void init() {
        mMap = getMap(); <----------- NPE when launched on older Android devices
        mMap.setMyLocationEnabled(true);
        mMap.setTrafficEnabled(true);
    }

    @Override
    public void onResume() {
        super.onResume();
        init();
    }
}

Thanks for helping.

In order to let Google Map API V2 to work on older devices you have to use the SupportMapFragment object instead of MapFragment object. So thats what you have to extend.

You have to use the SupportFragmentManager to get it's instance instead of the usually used FragmentManager .

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