Question

I have an Android application that runs Google Maps API v2. By using SupportMapFragment, I support devices running Android as back as API 8. I know Google Maps API v1 is deprecated and that very few devices run Android API 7 or lower, but is there an easy way to define my layout such that for devices lower than API 8, Google Maps API v1 will be loaded?

Was it helpful?

Solution

I would simply suggest creating a separate Activity for API v2 and doing something like this in Activity that starts maps:

if (isGles20() && isApi8()) {
    startNewActivity();
} else {
    startOldActivity();
}

You will get some duplicated code, but that's what refacoring is for to extract common logic into some class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top