@@ -0,0 +1,2863 @@
+/*%0A * Copyright 2012 Google Inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.google.android.gcm;%0A%0Aimport static com.google.android.gcm.GCMConstants.DEFAULT_INTENT_SERVICE_CLASS_NAME;%0A%0Aimport android.app.Activity;%0Aimport android.content.BroadcastReceiver;%0Aimport android.content.Context;%0Aimport android.content.Intent;%0Aimport android.util.Log;%0A%0A/**%0A * %7B@link BroadcastReceiver%7D that receives GCM messages and delivers them to%0A * an application-specific %7B@link GCMBaseIntentService%7D subclass.%0A * %3Cp%3E%0A * By default, the %7B@link GCMBaseIntentService%7D class belongs to the application%0A * main package and is named%0A * %7B@link GCMConstants#DEFAULT_INTENT_SERVICE_CLASS_NAME%7D. To use a new class,%0A * the %7B@link #getGCMIntentServiceClassName(Context)%7D must be overridden.%0A */%0Apublic class GCMBroadcastReceiver extends BroadcastReceiver %7B%0A%0A    private static final String TAG = %22GCMBroadcastReceiver%22;%0A    private static boolean mReceiverSet = false;%0A%0A    @Override%0A    public final void onReceive(Context context, Intent intent) %7B%0A        Log.v(TAG, %22onReceive: %22 + intent.getAction());%0A        // do a one-time check if app is using a custom GCMBroadcastReceiver%0A        if (!mReceiverSet) %7B%0A            mReceiverSet = true;%0A            String myClass = getClass().getName();%0A            if (!myClass.equals(GCMBroadcastReceiver.class.getName())) %7B%0A                GCMRegistrar.setRetryReceiverClassName(myClass);%0A            %7D%0A        %7D%0A        String className = getGCMIntentServiceClassName(context);%0A        Log.v(TAG, %22GCM IntentService class: %22 + className);%0A        // Delegates to the application-specific intent service.%0A        GCMBaseIntentService.runIntentInService(context, intent, className);%0A        setResult(Activity.RESULT_OK, null /* data */, null /* extra */);%0A    %7D%0A%0A    /**%0A     * Gets the class name of the intent service that will handle GCM messages.%0A     */%0A    protected String getGCMIntentServiceClassName(Context context) %7B%0A        return getDefaultIntentServiceClassName(context);%0A    %7D%0A%0A    /**%0A     * Gets the default class name of the intent service that will handle GCM%0A     * messages.%0A     */%0A    static final String getDefaultIntentServiceClassName(Context context) %7B%0A        String className = context.getPackageName() +%0A                DEFAULT_INTENT_SERVICE_CLASS_NAME;%0A        return className;%0A    %7D%0A%7D%0A

Create GCMBroadcastReceiver.java