Note that there are some explanatory texts on larger screens.

plurals
  1. POGCMBroadcastReceiver not fired
    primarykey
    data
    text
    <p>I have library project that is using GCM. I am trying to use not deprecated way without gcm.jar. Let's start from manifest of application project (not library):</p> <p>Here I have package set</p> <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.sennin.app" </code></pre> <p>Here I create my permission:</p> <pre><code>&lt;permission android:name="com.sennin.app.permission.C2D_MESSAGE" android:protectionLevel="signature" /&gt; </code></pre> <p>And here I use it with others:</p> <pre><code>&lt;uses-permission android:name="com.sennin.app.permission.C2D_MESSAGE"/&gt; &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/&gt; &lt;uses-permission android:name="android.permission.INTERNET"/&gt; &lt;uses-permission android:name="android.permission.WAKE_LOCK"/&gt; &lt;uses-permission android:name="android.permission.GET_ACCOUNTS"/&gt; &lt;uses-permission android:name="android.permission.USE_CREDENTIALS"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt; &lt;uses-permission android:name="android.permission.VIBRATE" /&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; </code></pre> <p>Here is receiver and IntentService entry:</p> <pre><code> &lt;receiver android:name="com.sennin.app.SenninGCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" &gt; &lt;intent-filter&gt; &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt; &lt;action android:name="com.google.android.c2dm.intent.REGISTRATION" /&gt; &lt;category android:name="com.sennin.app" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;service android:name="com.sennin.app.GCMIntentService" /&gt; </code></pre> <p>I know that receiver action <code>com.google.android.c2dm.intent.REGISTRATION</code> is in theory redundant but this is hack to make registration work with older devices (found on stackoverflow by the way).</p> <p>I need to add that my library has package <code>com.sennin</code>.</p> <p>Ok now let's go to the receiver itself:</p> <pre><code>public class SenninGCMBroadcastReceiver extends WakefulBroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.i("GCM", "RECEIVE GCM"); // Explicitly specify that GcmIntentService will handle the intent. ComponentName comp = new ComponentName(context.getPackageName(), GCMIntentService.class.getName()); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK); } } </code></pre> <p>In first line onReceive method is, as you can see <code>Log</code>. This log is important and all I want is to see this log in <code>logcat</code>;)</p> <p>I omitted registration part of messaging process because registration is working well. I have <code>registration_id</code> I send it to server. On the server site I put <code>registration_id</code> to datastore. After that I am just trying to send some messages. I can see on server side that message was sent. I have message_id and no errors. Everything seems to be just well, but receiver never get called. I want to see this log in <code>onReceive()</code> method but it's never happen.</p> <p>Is there any obvious mistake? Maybe I just don't wanna find it;)</p> <p>I want just add that I have been tested it on Android 2.3 and Android 4.0.3.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload