Not all android real machines contain Google map add-on.
If we develop an android application that uses Google map add-on ),
You will find that this program cannot be successfully installed on a real machine without the built-in Google map add-on.
Applications cannot be installed, which is a tough problem.
At least tell the user why not install it.
The following is a solution: (not the best. The best thing is that if Google map is not found in the real machine, I will add it to the program !)
There are two methods:
1) maintain two code branches:
One branch is for Android real machines with built-in Google map add-on,
The other branch is an android real machine with no built-in Google map add-on.
However, this will increase maintenance costs, and careless users may install mismatched branches on their own machines,
This reduces the software friendliness.
2) keep only one code Branch:
A foreign Daniel pointed out that the tag also contains an unpublished attribute "Android: required ",
You can set this attribute of the COM. Google. Android. Maps library to false, that is:
<! -- The "Android: required" attribute was added in API Level 5 (Android 2.0) -->
<Uses-library Android: Name = "com. Google. Android. Maps"Android: required = "false"/>
This means that if Google map add-on is built into the target machine,
The application can be used normally;
If the target machine does not have a built-in Google map add-on, you can also install the application.
However, developers must determine whether Google map add-on is available in the code,
Example:
Try {
Class. forname ("com. Google. Android. Maps. mapactivity ");
} Catch (exception e ){
Toast. maketext (mainactivity. This, "Oop! Google map unavailable ", Toast. length_short). Show ();
Return;
}
Intent intent = new intent ();
Intent. setclass (mainactivity. This, mymapactivity. Class );
Startactivity (intent );
Reference website:
[1] http://stackoverflow.com/questions/3909903/disable-mapview-if-it-is-not-supported
[2] http://androidforums.com/application-development/140147-does-all-android-devices-support-map-api.html