title: SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (has extras) }
body: <p>I try to get my GCM registrationId from Google.</p>
  
  <p>my code:</p>
  
  <pre><code>String SENDER_ID = "722******53";
  
  /**
   * Registers the application with GCM servers asynchronously.
   * &lt;p&gt;
   * Stores the registration ID and the app versionCode in the application's
   * shared preferences.
   */
  private void registerInBackground() {
      new AsyncTask&lt;Void, Void, String&gt;() {
          @Override
          protected String doInBackground(Void... params) {
              String msg = "";
              try {
                  if (gcm == null) {
                      gcm = GoogleCloudMessaging.getInstance(context);
                  }
                  regid = gcm.register(SENDER_ID);
                  msg = "Device registered, registration ID=" + regid;
  
                  // You should send the registration ID to your server over
                  // HTTP, so it
                  // can use GCM/HTTP or CCS to send messages to your app.
                  sendRegistrationIdToBackend();
  
                  // For this demo: we don't need to send it because the
                  // device will send
                  // upstream messages to a server that echo back the message
                  // using the
                  // 'from' address in the message.
  
                  // Persist the regID - no need to register again.
                  storeRegistrationId(context, regid);
              } catch (IOException ex) {
                  msg = "Error :" + ex.getMessage();
                  // If there is an error, don't just keep trying to register.
                  // Require the user to click a button again, or perform
                  // exponential back-off.
              }
              return msg;
          }
  
          @Override
          protected void onPostExecute(String msg) {
              mDisplay.append(msg + "\n");
          }
      }.execute(null, null, null);
  }
  </code></pre>
  
  <p>I get an error:</p>
  
  <pre><code>03-01 19:15:36.261: E/AndroidRuntime(3467): FATAL EXCEPTION: AsyncTask #1
  03-01 19:15:36.261: E/AndroidRuntime(3467): java.lang.RuntimeException: An error occured while executing doInBackground()
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at java.util.concurrent.FutureTask.run(FutureTask.java:239)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at java.lang.Thread.run(Thread.java:841)
  03-01 19:15:36.261: E/AndroidRuntime(3467): Caused by: java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (has extras) } without permission com.google.android.c2dm.permission.RECEIVE
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at android.app.ContextImpl.startServiceAsUser(ContextImpl.java:1800)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at android.app.ContextImpl.startService(ContextImpl.java:1772)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at android.content.ContextWrapper.startService(ContextWrapper.java:480)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at com.google.android.gms.gcm.GoogleCloudMessaging.b(Unknown Source)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at com.example.gcm.DemoActivity$1.doInBackground(DemoActivity.java:177)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at com.example.gcm.DemoActivity$1.doInBackground(DemoActivity.java:1)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
  03-01 19:15:36.261: E/AndroidRuntime(3467):     ... 4 more
  </code></pre>
  
  <p>here is my manifest:</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.example.manyexampleapp"
      android:installLocation="preferExternal"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="11"
          android:targetSdkVersion="18" /&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&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="com.example.manyexampleapp.c2dm.permission.RECEIVE" /&gt;
      &lt;uses-permission android:name="com.example.manyexampleapp.gcm.permission.C2D_MESSAGE" /&gt;
  
      &lt;permission
          android:name="com.example.manyexampleapp.gcm.permission.C2D_MESSAGE"
          android:protectionLevel="signature" /&gt;
  
      &lt;application
          android:name="com.zoomer.ifs.BaseApplication"
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;meta-data
              android:name="com.google.android.gms.version"
              android:value="@integer/google_play_services_version" /&gt;
  
  
           &lt;activity
              android:name="com.zoomer.ifs.MainActivity"
              android:label="@string/app_name"
              android:configChanges="orientation|keyboardHidden|screenSize"
                  android:launchMode="singleTop"&gt;
  &lt;!--             &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; --&gt;
          &lt;/activity&gt;
  
       &lt;!--     PUSH --&gt;
  
          &lt;!--
            WakefulBroadcastReceiver that will receive intents from GCM
            services and hand them to the custom IntentService.
  
            The com.google.android.c2dm.permission.SEND permission is necessary
            so only GCM services can send data messages for the app.
          --&gt;
          &lt;receiver
              android:name="com.example.gcm.GcmBroadcastReceiver"
              android:permission="com.google.android.c2dm.permission.SEND" &gt;
              &lt;intent-filter&gt;
                  &lt;!-- Receives the actual messages. --&gt;
                  &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt;
                  &lt;category android:name="com.example.manyexampleapp" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
          &lt;service android:name="com.example.gcm.GcmIntentService" /&gt;
  
           &lt;activity
              android:name="com.example.gcm.DemoActivity"&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;!--     DB --&gt;
          &lt;activity
              android:name="com.example.db.DbActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.example.http.RestGetActivity"
              android:label="@string/app_name"
              android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.example.fb.FacebookLoginActivity"
              android:label="@string/app_name" &gt;
  
              &lt;!--
                        &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;
              --&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.example.http.SendFeedbackActivity"
              android:label="@string/app_name" &gt;
  
              &lt;!--
                   &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;
              --&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.zoomer.general.SearchNearbyOffersActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.facebook.LoginActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name="com.example.manyexampleapp.StoresListActivity" &gt;
              &lt;intent-filter&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name="com.example.fb.ShareActivity" &gt;
              &lt;intent-filter&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name="com.example.notifications.NotificationsActivity" &gt;
              &lt;intent-filter&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name="com.example.fb2.no_use.MainActivity" &gt;
              &lt;intent-filter&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name="com.zoomer.offers.OffersListActivity" &gt;
  
              &lt;!--
                   &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;
              --&gt;
          &lt;/activity&gt;
          &lt;activity android:name="com.example.http.SearchNearbyOffersActivity" &gt;
  &lt;!--             &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; --&gt;
          &lt;/activity&gt;
  
          &lt;service
              android:name="com.example.geo.LocationService"
              android:enabled="true" /&gt;
  
          &lt;receiver android:name="com.example.manyexampleapp.BootReceiver" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
                  &lt;action android:name="com.example.manyexampleapp.LocationService.LOCATION_BROAD_MSG" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
  
          &lt;meta-data
              android:name="com.facebook.sdk.ApplicationId"
              android:value="@string/app_id" /&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>