Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8530867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:21:13+00:00 2026-06-11T09:21:13+00:00

I had use GCM service on my app , I did my code after

  • 0

I had use GCM service on my app , I did my code after more resarches also from stack overflow members , and when I try to test the code on my emulator I didn’t find any regiser info that tell me that my emulator is registered .Also I created my account on Google API to recienve any reports but I didn’t find any thing. So I need your help on:

1- please check my code and till my when the error I will feedback you with complete example :

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

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

    <permission
        android:name="com.example.elarabygroup.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.example.elarabygroup.permission.C2D_MESSAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />


    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".ElarabyGroup"
            android:label="@string/title_activity_elaraby_group" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </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.example.elarabygroup" />
            </intent-filter>
        </receiver>

        <service android:name=".GCMIntentService" />
        <!--
            android:name=".GCMIntentService"
            android:enabled="true" />
        -->
    </application>

</manifest>

package com.example.elarabygroup;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebView;
import com.google.android.gcm.GCMRegistrar;


public class ElarabyGroup extends Activity {
    private String TAG;
    private String SENDER_ID = "222874571774";
    private WebView webView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_elaraby_group);

        try {

            Intent registrationIntent = new Intent(
                    "com.google.android.c2dm.intent.REGISTER");

            /* Registering for GCM /An Android application needs to register with GCM servers before it can receive messages*/
            registrationIntent.putExtra("app",
                    PendingIntent.getBroadcast(this, 0, new Intent(), 0));
            registrationIntent.putExtra("sender", SENDER_ID);
            startService(registrationIntent);

            Log.i(TAG, "[checkNotifRegistration] checkDevice");
            GCMRegistrar.checkDevice(this);
            Log.i(TAG, "[checkNotifRegistration] checkManifest");
            GCMRegistrar.checkManifest(this);
            if (GCMRegistrar.isRegistered(this)) {
                Log.i(TAG,
                        "[checkNotifRegistration] reg id : "
                                + GCMRegistrar.getRegistrationId(this));
            }
            final String regId = GCMRegistrar.getRegistrationId(this);
            if (regId.equals("")) {
                // SENDER_ID is my project id into google account url
                GCMRegistrar.register(this, SENDER_ID);
                Log.i(TAG,
                        "[checkNotifRegistration] reg id : "
                                + GCMRegistrar.getRegistrationId(this));

            } else {
                Log.i(TAG, "[checkNotifRegistration] already registered as : "
                        + regId);
            }
        } catch (Exception e) {
            Log.e(TAG, "[checkNotifRegistration] Exception : " + e.getMessage());
            e.printStackTrace();
        }

        /*
         * GCMRegistrar.checkDevice(this); GCMRegistrar.checkManifest(this);
         * 
         * 
         * final String regId = GCMRegistrar.getRegistrationId(this); if
         * (regId.equals("")) { GCMRegistrar.register(this, "1111111111"); }
         * else { Log.v(TAG, "Already registered"); }
         */
        try {

            ConnectivityManager con = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

            if (con.getNetworkInfo(0).getState() == NetworkInfo.State.DISCONNECTED
                    && con.getNetworkInfo(1).getState() == NetworkInfo.State.DISCONNECTED) {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);

                builder.setMessage("No Internet connection");
                AlertDialog alert = builder.create();
                alert.show();

            } else

            {

                webView = (WebView) findViewById(R.id.webView1);
                webView.getSettings().setJavaScriptEnabled(true);
                webView.loadUrl("http://m.elarabygroup.com");
            }

        } catch (Exception e) {

            AlertDialog.Builder builder = new AlertDialog.Builder(this);

            builder.setMessage(e.getMessage().toString());

            AlertDialog alert = builder.create();

            String url = "http://m.elarabygroup.com/";

            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            startActivity(i);

        }

    }
    /*
    public class MyBroadcastReceiver extends BroadcastReceiver {

        @Override
        public final void onReceive(Context context, Intent intent) {
            GCMIntenetService.runIntentInService(context, intent);
            setResult(Activity.RESULT_OK, null, null);
        }
    }
    */

}
/*
 * @Override public boolean onCreateOptionsMenu(Menu menu) {
 * getMenuInflater().inflate(R.menu.activity_elaraby_group, menu); return true;
 * } }
 */

package com.example.elarabygroup;

import com.google.android.gcm.GCMBaseIntentService;
import com.google.android.gcm.GCMRegistrar;

import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import android.provider.Settings.Secure;
import android.util.Log;

public class GCMIntenetService extends GCMBaseIntentService {
    private static  String GCM_SENDER_ID = "1111111111111";

    public GCMIntenetService() {
        super();
    }

    @Override
    protected void onRegistered(Context context, String registrationId) {
        Log.i(TAG, "Device registered: regId = " + registrationId);
        GCMRegistrar.setRegisteredOnServer(context, true);
    }

    @Override
    protected void onUnregistered(Context context, String registrationId) {
        Log.i(TAG, "Device unregistered");
        if (GCMRegistrar.isRegisteredOnServer(context)) {
            String regId = "";
            Log.i(TAG, "unregistering device (regId = " + regId + ")");
            GCMRegistrar.setRegisteredOnServer(context, false);
        } else {
            // This callback results from the call to unregister made on
            // ServerUtilities when the registration to the server failed.
            Log.i(TAG, "Ignoring unregister callback");
        }
    }

    @Override
    protected void onError(Context context, String errorId) {
        // push error processing
    }

    @Override
    protected void onMessage(Context arg0, Intent arg1) {
        Log.i(TAG, "Received message");
        Log.i(TAG, "EXTRAS" + arg1.getExtras());
        // String message = getString(R.string.gcm_message);
        generateNotification(arg0,
                arg1.getStringExtra("Please download our new updates"));
        // notifies user about message

    }

    private void generateNotification(Context arg0, String stringExtra) {
        // TODO Auto-generated method stub

    }

    public static void registerInGCMService(Context context) {

        GCM_SENDER_ID = Secure.getString(context.getContentResolver(),
                Secure.ANDROID_ID);


        if (!checkIsGCMServiceAvailable(context)) {
            return;
        }
        final String regId = GCMRegistrar.getRegistrationId(context);
        if (regId.equals("")) {
            try {
                GCMRegistrar.register(context, GCM_SENDER_ID);
            } catch (Exception ex) {
            }
        } else {
            // Already registered
        }

    }

    public static boolean checkIsGCMServiceAvailable(Context context) {
        try {
            GCMRegistrar.checkDevice(context);
            GCMRegistrar.checkManifest(context);
            return true;
        } catch (Throwable th) {
            return false;
        }
    }

}

I had attached my log cat message

2- what about status in my Google API account

Service Status
Google Cloud Messaging for Android No known issues

Log cat

emulator message

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:21:14+00:00Added an answer on June 11, 2026 at 9:21 am

    first set your emulator target to Google API and add an google account to your emulator.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to Remove Badge from the tabbar item i had use below code but
I have created an app in which I had use SPenSDK to create image
I had to use a Microsoft Web Services Enhancements 2.0 service and it raised
Suppose I have had to use git filter-branch to remove a file from revision
Below is my code.... i had use an map here..instead of map i want
I had use listbox.itemsource as my e.Result. <ListBox Height=476 HorizontalAlignment=Left Margin=11,17,0,0 Name=ListBox1 VerticalAlignment=Top Width=434
i had use the spring3.1 ibatis2.x and mysql5.5. then i wanna use the replication
I had created one HTML page for my experiance. In this i had use
I have been frustrated that I have had to use the very buggy XCode
I came across a scenario where I had to use Union all, how can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.