在ICE CREAM SANDWICH之前使用Google Cloud后端和GCM for android版本

时间:2014-02-15 07:05:44

标签: android google-app-engine google-cloud-messaging

我尝试关注this tutorial以使用Google Cloud Engine部署后端,然后我按照thisthis注册推送通知GCM以运行示例项目并取得了成功。
问题是我的应用程序需要支持Android版本2.2+(api级别8),但云后端要求最低API级别为15(ICE CREAM SANDWICH MR1)。
我尝试将api级别设置为8,然后用支持包库替换所有片段和活动,但它在运行时给了我一个异常Failure delivering result

   02-15 13:41:23.266: E/AndroidRuntime(5209): FATAL EXCEPTION: main
   02-15 13:41:23.266: E/AndroidRuntime(5209): Process: com.google.cloud.backend, PID: 5209
   02-15 13:41:23.266: E/AndroidRuntime(5209): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=0, data=null} to activity {com.google.cloud.backend/com.google.cloud.backend.sample.guestbook.GuestbookActivity}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at android.app.ActivityThread.deliverResults(ActivityThread.java:3488)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at android.app.ActivityThread.handleSendResult(ActivityThread.java:3531)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at android.app.ActivityThread.access$1300(ActivityThread.java:157)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1295)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at android.os.Handler.dispatchMessage(Handler.java:102)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at android.os.Looper.loop(Looper.java:157)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at android.app.ActivityThread.main(ActivityThread.java:5293)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at java.lang.reflect.Method.invokeNative(Native Method)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at java.lang.reflect.Method.invoke(Method.java:515)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1259)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at dalvik.system.NativeStart.main(Native Method)
   02-15 13:41:23.266: E/AndroidRuntime(5209): Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1343)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1354)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:595)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:574)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at com.google.cloud.backend.sample.guestbook.GuestbookActivity.initiateFragments(GuestbookActivity.java:212)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at com.google.cloud.backend.sample.guestbook.GuestbookActivity.onActivityResult(GuestbookActivity.java:168)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at android.app.Activity.dispatchActivityResult(Activity.java:5581)
   02-15 13:41:23.266: E/AndroidRuntime(5209):  at android.app.ActivityThread.deliverResults(ActivityThread.java:3484)

有没有其他方法可以让它在Android API级别低于15?由于GCM支持最低级别2.2+,来自the document

  

在设备上运行的启用GCM的Android应用程序。这个   必须是安装了Google Play商店的2.2 Android设备   如果设备是,则必须至少有一个已登录的Google帐户   运行低于Android 4.0.4的版本。或者,为   测试您可以使用运行Android 2.2和Google API的模拟器。

更新:我只是从Google运行this example并将所有Fragment更改为android.support.v4.app.Fragment,将Activity更改为android.support.v4.app.FragmentActivity,因为我将manifest中的minSdkVersion更改为8。

0 个答案:

没有答案