我正在尝试处理用户未正确设置 Play 的用例。这似乎非常简单,但我无法让对话框做任何事情。我有以下代码onCreate
用于FragmentActivity
使用Maps v2
. 我确保执行确实在 if 语句中进行。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
this.helper = (DatabaseHelper) OpenHelperManager.getHelper(this, DatabaseHelper.class);
int googlePlayStatus = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if(googlePlayStatus != ConnectionResult.SUCCESS) {
if(GooglePlayServicesUtil.isUserRecoverableError(googlePlayStatus)) {
GooglePlayServicesUtil.getErrorDialog(googlePlayStatus, this, googlePlayStatus).show();
}
}
//... do some stuff, such as use CameraUpdateFactory which throws NPE.
}
我尝试将代码插入另一个活动,而不进行 if 检查,并且对话框显示得很好。