【发布时间】:2013-11-07 16:24:55
【问题描述】:
我正在尝试处理用户未正确设置 Play 的用例。这似乎非常简单,但我无法让对话框做任何事情。我在onCreate 中有以下代码,用于使用Maps v2 的FragmentActivity。我确保执行确实在 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 检查,对话框显示正常。
【问题讨论】:
-
without the if checks。 if 条件的计算结果是什么? -
@njzk2 抱歉,我已经检查过执行是否在 if 语句中。
getErrorDialog调用什么也没做。 -
你确定你现在在ui线程上吗?
-
@njzk2 我想是的,我在
onCreate方法中。 -
你能多贴一点上下文代码吗?
标签: android google-play-services android-maps-v2