title: GCM not receiving untill run SuperVPN
body: <p>I have written an application, and in this application I can send a notification to users. In the first version, there were no problems. Then I made revisions with the same key, and I began experiencing problems.</p>
  
  <p>Some devices no longer receive any notification, and one of these devices is my device. Later, I discovered that my device and others are no longer accepting any notification from GCM service, even though I put the new version of my app with GCM along with the new key or any app has GCM.</p>
  
  <p>This problem has been reported to me by others who have updated to the new version of my app . But some users who updated the application works with them without any problems. I mean for some users, the app continues to work correctly.‏</p>
  
  <p>when I run SuperVPN app all notifications delivered ! 
  so two devices connected to same router 
  first one get notifications normally 
  other one not receiving without SuperVPN </p>
  
  <p><strong>manifist.xml</strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.labyb.englishwordeachday"
      android:versionCode="2"
      android:versionName="2.0.0" &gt;
  
      &lt;uses-sdk android:minSdkVersion="11" /&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
      &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="com.android.alarm.permission.SET_ALARM" /&gt;
      &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
      &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
  
      &lt;permission
          android:name="com.labyb.englishwordeachday.permission.C2D_MESSAGE"
          android:protectionLevel="signature" /&gt;
  
      &lt;uses-permission android:name="com.labyb.englishwordeachday.permission.C2D_MESSAGE" /&gt;
  
  
      &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name="com.labyb.englishwordeachday.WordActivity"
              android:label="@string/app_name"
              android:parentActivityName=".AllWordsActivity"
              android:screenOrientation="portrait"
              android:windowSoftInputMode="stateHidden" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.labyb.englishwordeachday.AddsActivity"
              android:label="@string/title_activity_adds"
              android:screenOrientation="portrait" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.labyb.englishwordeachday.AllWordsActivity"
              android:label="@string/title_activity_list"
              android:screenOrientation="portrait" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.labyb.englishwordeachday.SplashActivity"
              android:label="@string/title_activity_splash"
              android:screenOrientation="portrait" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.labyb.englishwordeachday.SearchActivity"
              android:label="@string/title_activity_search"
              android:screenOrientation="portrait"
              android:theme="@android:style/Theme.Holo.Light.Dialog" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.labyb.englishwordeachday.TranslateActivity"
              android:label="@string/title_activity_translate"
              android:theme="@android:style/Theme.Holo.Light.Dialog" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.labyb.englishwordeachday.TestActivity"
              android:label="@string/title_activity_test_new" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.labyb.englishwordeachday.ReminderActivity"
              android:label="@string/title_activity_reminder"
              android:theme="@android:style/Theme.Holo.Light.Dialog" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.labyb.englishwordeachday.SetReminderActivity"
              android:label="@string/title_activity_set_reminder"
              android:theme="@android:style/Theme.Holo.Light.Dialog" &gt;
          &lt;/activity&gt;
  
          &lt;receiver android:name="com.labyb.englishwordeachday.MyReceiver" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.labyb.englishwordeachday.mybroadcast" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
  
          &lt;activity
              android:name="com.labyb.englishwordeachday.RemindersActivity"
              android:label="@string/title_activity_reminders" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.labyb.englishwordeachday.SpeachActivity"
              android:label="@string/title_activity_speach"
              android:theme="@android:style/Theme.Holo.Light.Dialog" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.labyb.englishwordeachday.LevelsActivity"
              android:label="@string/title_activity_levels" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.labyb.englishwordeachday.WebActivity"
              android:label="@string/title_activity_web" &gt;
          &lt;/activity&gt;
  
          &lt;receiver
              android:name="com.labyb.englishwordeachday.GcmBroadcastReceiver"
              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.labyb.englishwordeachday" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
  
          &lt;service android:name="com.labyb.englishwordeachday.GcmIntentService" /&gt;
  
          &lt;receiver android:name=".StartUpBootReceiver" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
                  &lt;action android:name="android.intent.action.QUICKBOOT_POWERON" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>GcmBroadcastReceiver.java</strong></p>
  
  <pre><code>package com.labyb.englishwordeachday;
  
  import android.app.Activity;
  import android.content.ComponentName;
  import android.content.Context;
  import android.content.Intent;
  import android.support.v4.content.WakefulBroadcastReceiver;
  
  public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
  
      @Override
      public void onReceive(Context context, Intent intent) {
          ComponentName comp = new ComponentName(context.getPackageName(),
                  GcmIntentService.class.getName());
          startWakefulService(context, (intent.setComponent(comp)));
          setResultCode(Activity.RESULT_OK);
      }
  }
  </code></pre>
  
  <p><strong>GcmIntentService.java</strong></p>
  
  <pre><code>    package com.labyb.englishwordeachday;
  
      import android.app.IntentService;
      import android.app.NotificationManager;
      import android.app.PendingIntent;
      import android.content.Context;
      import android.content.Intent;
      import android.net.Uri;
      import android.os.Bundle;
      import android.os.SystemClock;
      import android.support.v4.app.NotificationCompat;
      import android.util.Log;
  
      import com.google.android.gms.gcm.GoogleCloudMessaging;
      import com.labyb.englishwordeachday.classes.Adds;
      import com.labyb.englishwordeachday.classes.DatabaseHandler;
  
      public class GcmIntentService extends IntentService {
          public static final int NOTIFICATION_ID = 1;
          private NotificationManager mNotificationManager;
          NotificationCompat.Builder builder;
          DatabaseHandler db;
          static int counter = 0;
  
      public GcmIntentService() {
          super("GcmIntentService");
      }
  
      public static final String TAG = "GCM Demo";
  
      @Override
      protected void onHandleIntent(Intent intent) {
  
          Bundle extras = intent.getExtras();
          GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
          String messageType = gcm.getMessageType(intent);
          if (!extras.isEmpty()) {
              if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
                  sendNotification("Send error: " + extras.toString(), "Send error: " + extras.toString(), "Send error: " + extras.toString(), "Send error: " + extras.toString(), "Send error: "
                          + extras.toString(), "Send error: " + extras.toString(), "Send error: " + extras.toString(), "Send error: " + extras.toString(), "Send error: " + extras.toString());
              } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
                  sendNotification("Deleted messages on server: " + extras.toString(), "Deleted messages on server: " + extras.toString(), "Deleted messages on server: " + extras.toString(),
                          "Deleted messages on server: " + extras.toString(), "Deleted messages on server: " + extras.toString(), "Deleted messages on server: " + extras.toString(),
                          "Deleted messages on server: " + extras.toString(), "Deleted messages on server: " + extras.toString(), "Deleted messages on server: " + extras.toString());
              } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
                  // for (int i = 0; i &lt; 5; i++) {
                  // Log.i(TAG, "Working... " + (i + 1) + "/5 @ " +
                  // SystemClock.elapsedRealtime());
                  // try {
                  // Thread.sleep(5000);
                  // } catch (InterruptedException e) {
                  // }
                  // }
                  Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());
                  sendNotification(extras.get("word_id").toString(), extras.get("m1").toString(), extras.get("m2").toString(), extras.get("m3").toString(), extras.get("m4").toString(), extras.get("m5")
                          .toString(), extras.get("m6").toString(), extras.get("m7").toString(), extras.get("level").toString());
                  Log.i(TAG, "Received: " + extras.toString());
              }
          }
          GcmBroadcastReceiver.completeWakefulIntent(intent);
      }
  
      long[] vibraPattern = { 500, 500, 500, 500 };
  
      private void sendNotification(String word_id, String m1, String m2, String m3, String m4, String m5, String m6, String m7, String level) {
          mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
          if (m4.equals("v1")) {
  
          } else if (m1.equals("newadd")) {
  
  
              Intent myIntent = new Intent(this, AddsActivity.class);
              PendingIntent contentIntent = PendingIntent.getActivity(this, 1, myIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  
              NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_launcher).setContentTitle("قد يهمك ايضا")
                      .setStyle(new NotificationCompat.BigTextStyle().bigText(m2)).setAutoCancel(true).setTicker("قد يهمك ايضا").setVibrate(vibraPattern)
                      .setSound(Uri.parse("android.resource://" + this.getPackageName() + "/" + R.raw.ewed)).setContentText(m2);
  
              mBuilder.setContentIntent(contentIntent);
              mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
              counter = counter + 1;
  
              db = new DatabaseHandler(this);
              db.addAdd(new Adds(m3, m2));// /hereeeeeeeeeeeeee
          } else {
              Intent i = new Intent(this, WordActivity.class);
              i.putExtra("id", word_id);
              PendingIntent contentIntent = PendingIntent.getActivity(this, 1, i, PendingIntent.FLAG_UPDATE_CURRENT);
  
  
              NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_launcher).setContentTitle(m1)
                      .setStyle(new NotificationCompat.BigTextStyle().bigText(m1)).setAutoCancel(true).setTicker("كلمة إنجليزية جديدة").setVibrate(vibraPattern)
                      .setSound(Uri.parse("android.resource://" + this.getPackageName() + "/" + R.raw.ewed)).setContentText(m2);
  
              mBuilder.setContentIntent(contentIntent);
              mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
              counter = counter + 1;
  
              db = new DatabaseHandler(this);
              db.addNewWord(word_id, m1, m2, m3, m4, m5, m6, m7, level);// /hereeeeeeeeeeeeee
          }
      }
  }
  </code></pre>