转自:http://www.cnblogs.com/moonvan/archive/2012/08/24/2654508.html
国外一位大牛指出:在<uses-library>标签中还包含了一个没有公布的属性"android:required",你可以将com.google.android.maps库的这个属性设置为false,即:
1
2
|
<!-- The "android:required" attribute was added in API level 5 (Android 2.0) -->
<
uses-library
android:name
=
"com.google.android.maps"
android:required
=
"false"
/>
|
这代表如果在目标机器上内置了Google Map add-on,则可以正常使用应用;如果目标机器没有内置Google Map add-on,也可以成功安装应用。但是开发人员需要在代码中自行判断Google Map add-on是否可用,举例如下:
01
02
03
04
05
06
07
08
09
10
|
try
{
Class.forName(
"com.google.android.maps.MapActivity"
);
}
catch
(Exception e) {
Toast.makeText(MainActivity.
this
,
"Oop! google地图不可用"
, Toast.LENGTH_SHORT).show();
return
;
}
Intent intent =
new
Intent();
intent.setClass(MainActivity.
this
, MyMapActivity.
class
);
startActivity(intent);
|