Android GCM instanceID.getToken() throws TIMEOUT exception on Gingerbread

牧云@^-^@ 提交于 2019-12-14 04:01:08

问题


As the title indicates I get a TIMEOUT exception when trying to get token using Google Cloud Messaging on API 10 emulator. I have added my google account on the device, checked that "Sync" is ON, also added the <action android:name="com.google.android.c2dm.intent.REGISTRATION"/> in the manifest in the receiver and still cannot find out what is causing this:

11-25 17:35:00.896 29750-29774/com.example.alexis.myapplication W/InstanceID/Rpc: No response android.os.ConditionVariable@b667bc18
11-25 17:35:00.896 29750-29774/com.example.alexis.myapplication E/MYAPP: TIMEOUT

Here is the manifest declaration for permissions:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<permission android:name="com.example.alexis.myapplication.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.example.alexis.myapplication.permission.C2D_MESSAGE" />

<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

And receiver:

<receiver
        android:name="com.google.android.gms.gcm.GcmReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>

            <!-- Receives the actual messages. -->
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />

            <!-- Receives the registration id. -->
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

            <category android:name="com.example.alexis.myapplication" />

        </intent-filter>
    </receiver>

Any help would be highly appreciated.

Note: I am using genymotion emulator with 2.3.7, I don't have a hardware device to test.


回答1:


Used a hardware device and everything worked so it was emulator's fault.



来源:https://stackoverflow.com/questions/33923223/android-gcm-instanceid-gettoken-throws-timeout-exception-on-gingerbread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!