I am currently developing an android application uses Google map API.
I am wondering do all android devices support map API, becuase this api is an optinal api and i
I needed to see if the library existed before attempting any calling, so I could fill the relevant preferences before-hand. Here's the code I came up with to check.
public static boolean hasSystemSharedLibraryInstalled(Context ctx,
String libraryName) {
boolean hasLibraryInstalled = false;
if (!TextUtils.isEmpty(libraryName)) {
String[] installedLibraries = ctx.getPackageManager()
.getSystemSharedLibraryNames();
if (installedLibraries != null) {
for (String s : installedLibraries) {
if (libraryName.equals(s)) {
hasLibraryInstalled = true;
break;
}
}
}
}
return hasLibraryInstalled;
}
And then I check to see if com.google.android.maps
is installed.
You are right, some Devices, like Archos 5IT and Some Tablet does not have Google Maps, Android Market, etc...
Here is my Code. BelgianMap is a MapActivity:
try {
Intent i = new Intent(InfoGare.this, BelgianMap.class);
startActivityForResult(i, 0);
}
catch(ActivityNotFoundException e) {
Toast.makeText(context, "Google Map not found", Toast.LENGTH_LONG).show();
}
But maybe there is an other way to find that at the creation of your application and display a message. That might be better.