If you want to install an app with Google map add-on the android real machine, you need Google map add-on to the real machine itself. How can we install an app with no built-in real machine?
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-on<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 two code branches:
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 that the <uses-library> 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) --> <br/> <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;} intent = new intent (); intent. setclass (mainactivity. this, mymapactivity. class); startactivity (intent );Reprinted from http://www.cnblogs.com/gansc23/archive/2011/02/28/1967207.html