如何跟踪GCM问题?

时间:2012-09-06 06:08:56

标签: android google-cloud-messaging

我有一个问题,我只是没有得到任何GCM消息。我不想要Pop Ups或声音播放,它甚至不会触发广播接收器中的 onReceive()方法,据我所知,这是应用程序处理消息的第一点。

我最大的问题是我没有收到任何错误消息或提示。当我发送消息时,我得到消息ID,多播ID和“success = 1”消息。我还获得了“在任何设备上注册的设备和注册ID,已注册”第二次运行应用程序。设备也登录到Google Play,与Google API控制台上的帐户相同。但是没有任何操作发送GCM消息时的设备。

我发布完整的Android清单,如果您需要更多代码,请告诉我。这让我发疯了。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lottoapplicationandroid"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto"
 >

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="9" />

<supports-screens 
android:largeScreens="true" 
android:normalScreens="true" 
android:smallScreens="true" 
android:resizeable="true" 
android:anyDensity="true" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<permission android:name="com.lottoapplicationandroid.permission.C2D_MESSAGE"     android:protectionLevel="signature" />
<uses-permission android:name="com.lottoapplicationandroid.permission.C2D_MESSAGE" /> 
<!-- App receives GCM messages. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- GCM connects to Google Services. -->
<uses-permission android:name="android.permission.INTERNET" /> 
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main"
        android:configChanges="orientation|keyboardHidden" 
        android:screenOrientation="portrait">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <!-- ZXing activities -->
<activity android:name="com.google.zxing.client.android.CaptureActivity"
          android:screenOrientation="landscape"
          android:configChanges="orientation|keyboardHidden"
          android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
          android:windowSoftInputMode="stateAlwaysHidden">
  <intent-filter>
    <action android:name="com.phonegap.plugins.barcodescanner.SCAN"/>
    <category android:name="android.intent.category.DEFAULT"/>
  </intent-filter>
</activity>
<activity android:name="com.google.zxing.client.android.encode.EncodeActivity" android:label="@string/share_name">
  <intent-filter>
    <action android:name="com.phonegap.plugins.barcodescanner.ENCODE"/>
    <category android:name="android.intent.category.DEFAULT"/>
  </intent-filter>
</activity>


<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
 <action android:name="com.google.android.c2dm.intent.RECEIVE" />
 <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
 <category android:name="com.lottoapplicationandroid" />
</intent-filter>
</receiver>

<service android:name=".GCMIntentService" />

</application>

修改

如果不可能,我不需要解决方案。我非常感谢提示如何找出问题所在。例如。我发现我必须有一个开放的端口5228.有人知道如何检查设备是否正在侦听该端口吗?

3 个答案:

答案 0 :(得分:3)

问题已经解决。

我不得不关闭Wi-Fi。

  

WiFi /电话网

     

开/关:不工作

     

开/关:不工作

     

on / on:不工作

     

开/关:工作

答案 1 :(得分:0)

您是否错过了接收器的一些意图过滤器?

 <receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
      <intent-filter>
          <action android:name="com.google.android.c2dm.intent.RECEIVE" />
          <category android:name="com.lottoapplicationandroid" />
      </intent-filter>
      <intent-filter>
          <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
          <category android:name="com.lottoapplicationandroid" />
      </intent-filter>
 </receiver>

答案 2 :(得分:0)

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="packagename.permission.C2D_MESSAGE" />     

   <receiver
                    android:name=".MyBroadcastReceiver"
                    android:permission="com.google.android.c2dm.permission.SEND" >
                    <intent-filter>
                        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                        <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                        <category android:name="packagename" />
                    </intent-filter>
                </receiver>

      <service android:name="Packagename.MyIntentService" >
            </service>


Try it hope so it works.