GCM FC /发件人ID不能在构造函数中设置 [英] GCM FC / sender id not set on constructor

查看:187
本文介绍了GCM FC /发件人ID不能在构造函数中设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经得到了一些奇怪的踪迹,从我的应用程序的用户最近

I have gotten some strange StackTraces from users of my app recently:

Android Version: 2.3.5
Phone Model: GT-I9001
Stacktrace:
java.lang.IllegalStateException: sender id not set on constructor
at com.google.android.gcm.GCMBaseIntentService.getSenderIds(GCMBaseIntentService.java:125)
at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:237)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.os.HandlerThread.run(HandlerThread.java:60)

我现在用的GCM lib中的第3版以及有关的senderID并不需要由构造了传递的文件(是方式C2DM次) - 也这并不在我的设备,并在崩溃很多其他用户的设备。有人可以揭示什么是发生在这些设备上一盏灯,idealy具有一定的解决方法吗?非工作GCM对这些用户将是我的一个选择,因为设备的推是可选的 - 但我不希望它崩溃..

I am using Rev. 3 of the GCM lib and regarding to the documentation the senderID is not needed to be passed by the constructor anymore ( was that way in C2DM times ) - also this does not crash on my devices and on the devices of a lot of other users. Can somebody shed a light on what is happening on these devices and idealy has some workaround? A non working GCM for these users would be an option for me as device push is optional - but I do not want it to crash ..

编辑这里是用于来源: <一href="https://github.com/ligi/gobandroid/blob/master/src/org/ligi/gobandroid_hd/GCMIntentService.java">https://github.com/ligi/gobandroid/blob/master/src/org/ligi/gobandroid_hd/GCMIntentService.java

Edit here is the source used: https://github.com/ligi/gobandroid/blob/master/src/org/ligi/gobandroid_hd/GCMIntentService.java

推荐答案

你覆盖的方法 getSenderIds(上下文的背景下)从GCMBaseIntentService?从源头code,它提到的,如果你不通过的SenderID在构造函数中,那么你需要重写 getSenderIds(上下文的背景下)来提供一个SenderID。

Did you override the method getSenderIds(Context context) from GCMBaseIntentService? From the source code, it mentioned if you do not pass in a SenderID in the constructor, then you need to override getSenderIds(Context context) to provide a SenderID.

下面是从构造评论:

/**
 * Constructor that does not set a sender id, useful when the sender id
 * is context-specific.
 * <p>
 * When using this constructor, the subclass <strong>must</strong>
 * override {@link #getSenderIds(Context)}, otherwise methods such as
 * {@link #onHandleIntent(Intent)} will throw an
 * {@link IllegalStateException} on runtime.
 */
protected GCMBaseIntentService() {
    this(getName("DynamicSenderIds"), null);
}

和注释的getSenderIds():

And the comment for getSenderIds():

/**
 * Gets the sender ids.
 *
 * <p>By default, it returns the sender ids passed in the constructor, but
 * it could be overridden to provide a dynamic sender id.
 *
 * @throws IllegalStateException if sender id was not set on constructor.
 */
protected String[] getSenderIds(Context context) {
    if (mSenderIds == null) {
        throw new IllegalStateException("sender id not set on constructor");
    }
    return mSenderIds;
}

这篇关于GCM FC /发件人ID不能在构造函数中设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆