我在Android 4.2.2上在真实设备上运行makeGooglePlayServicesAvailable,它只是崩溃了下面的堆栈跟踪。我不知道这是否是makeGooglePlayServicesAvailable问题或错误消息中的更多内容?这个相同的代码在具有更高Android操作系统的模拟器上运行良好。
public class EventsActivity extends BaseActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
int success = googleApiAvailability.isGooglePlayServicesAvailable(this);
if(success != ConnectionResult.SUCCESS)
{
googleApiAvailability.makeGooglePlayServicesAvailable(this);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.drawer);
}
错误
Process: com.exposure, PID: 5713
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.EventsActivity}: java.lang.IllegalStateException: Activity has been destroyed
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2334)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
at android.app.ActivityThread.access$900(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5487)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: Activity has been destroyed
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1560)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:696)
at android.support.v4.app.BackStackRecord.commitAllowingStateLoss(BackStackRecord.java:667)
at com.google.android.gms.internal.zzabm.zza(Unknown Source)
at com.google.android.gms.internal.zzaaw.zzc(Unknown Source)
at com.google.android.gms.internal.zzaaw.zzs(Unknown Source)
at com.google.android.gms.internal.zzabb.zzu(Unknown Source)
at com.google.android.gms.common.GoogleApiAvailability.makeGooglePlayServicesAvailable(Unknown Source)
答案 0 :(得分:0)
在super.onCreate()
修复问题后调用它。