Reputation: 11
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.
Upvotes: 0
Views: 316
Reputation: 41099
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
.
Upvotes: 1