GCM class 转换异常

GCM class cast exception

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

异常:

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)

我将上下文用作 getApplicationContext,因为我已从意向服务中调用它。我该如何处理这个异常?

由于您无法显示来自服务的对话框,您可以改用 GooglePlaySErvicesUtil.showErrorNotification(),它允许您 post 提示用户通过 Google Play 解决错误的通知服务。