在之前的一个项目中使用了google map,在三星的一些手机上没问题,在华为的几款手机上出现了崩溃,后来调试发现是mMap= ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();这句代码返回了null 导致了后面的程序崩溃。后来网上查找发现是google的一些服务被阉割掉了导致的,在手机上安装google map 和 google play 之后程序就不再出现崩溃的问题。
对于系统阉割产生的问题,在程序运行初始时要对系统做一下检测。
int resultCode = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(this);
if (ConnectionResult.SUCCESS == resultCode) {
} else {
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode,
this, 0);
if (dialog != null) {
dialog.show();
}
}