嗨,我使用此链接,但这在Android 3.0中不起作用,但在2.0和2.2中工作
http://console.xtify.com/implementation-guide-android
错误是:
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): java.lang.RuntimeException: Unable to create service com.xtify.android.sdk.MainService: java.lang.IllegalArgumentException: provider=network
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2034)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at android.app.ActivityThread.access$2500(ActivityThread.java:123)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1047)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at android.os.Looper.loop(Looper.java:126)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at android.app.ActivityThread.main(ActivityThread.java:3997)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at java.lang.reflect.Method.invokeNative(Native Method)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at java.lang.reflect.Method.invoke(Method.java:491)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at dalvik.system.NativeStart.main(Native Method)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): Caused by: java.lang.IllegalArgumentException: provider=network
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at android.os.Parcel.readException(Parcel.java:1326)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at android.os.Parcel.readException(Parcel.java:1276)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:646)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at android.location.LocationManager._requestLocationUpdates(LocationManager.java:582)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at android.location.LocationManager.requestLocationUpdates(LocationManager.java:446)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at com.xtify.android.sdk.MainService.g(Unknown Source)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at com.xtify.android.sdk.MainService.onCreate(Unknown Source)
05-16 16:21:41.132: ERROR/AndroidRuntime(3583): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2024)
只需使用以下代码:
if (Build.VERSION.SDK_INT >= 8){
registerForC2dm();
} else {
// continue to use your pre-C2DM solution here for ex. MQTT library
}