简体   繁体   中英

GCM class cast exception

if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
        GooglePlayServicesUtil.getErrorDialog(resultCode, (Activity)  
     context, PLAY_SERVICES_RESOLUTION_REQUEST).show();
    } 

Exception:

java.lang.ClassCastException: com.interconnect.garhoud.Garhoud cannot be cast to android.app.Activity at com.interconnect.library.gcm.Util.checkPlayServices(Util.java:96) at com.interconnect.library.gcm.Regiseter.handleRegister(Regiseter.java:53) at com.interconnect.library.gcm.Regiseter.onHandleIntent(Regiseter.java:30) at android.app.IntentService$ServiceHandler.handleMessage
(IntentService.java:65) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:146) at android.os.HandlerThread.run(HandlerThread.java:61)

I have used context as getApplicationContext, because I have called that if from an intent service. How can I handle this exception?

由于无法显示服务中的对话框,因此可以改用GooglePlaySErvicesUtil.showErrorNotification() ,它使您可以发布通知,提示用户解决Google Play服务中的错误。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM