Not all android real machines contain Google map add-on. To build Google map add-on, you need to discuss it with Google.
However, if we develop an android application that uses Google map add-onProgram(That is<Uses-library Android: Name = "com. Google. Android. Maps"/>), You will find that this program cannot be successfully installed on a real machine without a built-in Google map add-on. So what can we do to solve this problem?
There are two methods:
1) maintain twoCodeBranch:
One branch is for Android real machines with built-in Google map add-on, and the other branch is for Android real machines without built-in Google map add-on.
However, this will increase the maintenance cost, and careless users may install mismatched branches on their own machines, thus reducing the software friendliness.
2) keep only one code Branch:
A foreign Daniel pointed out:<Uses-library>The tag also contains an unpublished attribute"Android: Required", You canCom. Google. Android. MapsThis attribute of the library is set 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 on the target machine, the application can be used normally. If Google map add-on is not built on the target machine, the application can be installed successfully. However, developers need to determine whether Google map add-on is available in the code, for 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 ;< BR >}< P>
intent = New intent ();
intent. setclass (mainactivity. This , mymapactivity. class );
startactivity (intent);