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

  • SEARCH
  • Home
  • 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 7866879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:32:27+00:00 2026-06-03T00:32:27+00:00

OK, I really don’t know what I’m lacking here. I try to get C2DM

  • 0

OK, I really don’t know what I’m lacking here. I try to get C2DM working for our application and especially handling the Broadcasts make me struggle.

We have an appwide BroadcastReceiver:

public final class AppBroadcastReceiver extends BroadcastReceiver {

    //get an instance if not already present
    public static AppBroadcastReceiver getInstance(final IntentFilter filter) {
        if (instance == null) {
            instance = new GlobalBroadcastReceiver();
        }
        if (filter != null) {
            filter.addAction("com.google.android.c2dm.intent.REGISTRATION";
            filter.addAction("com.google.android.c2dm.intent.RECEIVE");
            filter.addCategory("my.package.name");
        }
        return instance;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        final String broadcastAction = intent.getAction();
        Log.d(logTag, String.format("GlobalBroadcastReceiver::onReceive for action = %s", broadcastAction));

        if ("com.google.android.c2dm.intent.REGISTRATION".equals(broadcastAction)) {
            for (final AppBroadcastListener l : listeners) {
                l.c2dmRegistration(intent);
            }
        } else if ("com.google.android.c2dm.intent.RECEIVE".equals(broadcastAction)) {
            for (final ApplBroadcastListener l : listeners) {
                l.c2dmReceive(intent);
            }
        }//else
    }//onReceive
}

AppBroadcastListener is an interface all our activities are implementing to assure the appropriate method are at least present. In their onResume(), onStop() methods the activities registering and unregistered themselves at the Receiver, respectively.

For testing purposes I have a Debug Activity proving me the following two methods:

public void sendC2DM(View v){
    Intent intent= new Intent();
    intent.setAction(com.google.android.c2dm.intent.RECEIVE);
    intent.putExtra("message","Bender: \"kiss my shiny metal ass!\"");
    intent.addCategory(getPackageName() );

    sendBroadcast(intent);
}

public void registerC2DM(View v){
    Intent registrationIntent = new Intent(com.google.android.c2dm.intent.REGISTRATION);
    registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0)); // boilerplate
    registrationIntent.putExtra("sender", ourSenderIdregistered@googlemail.com);
    startService(registrationIntent);
}

And in the android.manifest I’ve added the follwoing lines in the <application>-tag:

    <receiver
        android:name=".AppBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >

        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />

            <category android:name="my.package.name" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

            <category android:name="my.package.name" />
        </intent-filter>
    </receiver>

So every activity we want to receive broadcast is registering itself at the BroadcastReceiver on it’s onResume() and when something is happening the BroadcastReceiver will catch and call the implemented methods. E.g. ,logging the message or displaying a Toast.

However when I send a “C2DM message” I see this structure is working for self crafted broadcast. (Bender’s message is popping up in a Toast) but registerC2DM().startService(registrationIntent); just logs:

Unable to start service Intent {
act=com.google.android.c2dm.intent.REGISTRATION (has extras) }: not
found

I’ve no clue what I’m missing here. General advice seems to be: check your android.manifest (done) or: log in with the registered gmail account.
Not sure bout this. I’m logged in with my gmail account yeah but not with ourSenderIdregistered@googlemail.com which we put in the intent when registering. I also strongly believe this can not be the solution. (Telling all our customers to log in with this account… ehm no?!).
So I guess it’s something else but I just can’t find it :C

  • 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-03T00:32:30+00:00Added an answer on June 3, 2026 at 12:32 am

    OK, this is really mean to spot:

    If you want to register for c2dm you use

    com.google.android.c2dm.intent.REGISTER
    

    but to catch the answer to this message you have to set up you’re broadcast receiver to listen to

    com.google.android.c2dm.intent.REGISTRATION
    

    Subtle? Yes, here once again the error and the corrected version:

    //false
    public void registerC2DM(View v){
        Intent registrationIntent = new Intent(com.google.android.c2dm.intent.REGISTRATION);
        registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0)); // boilerplate
        registrationIntent.putExtra("sender", ourSenderIdregistered@googlemail.com);
        startService(registrationIntent);
    }
    
    
    //true
    public void registerC2DM(View v){
        Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
    registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0)); // boilerplate
    registrationIntent.putExtra("sender", ourSenderIdregistered@googlemail.com);
        startService(registrationIntent);
    }
    

    Smashed 3 keyboards before realising this… 🙂

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

Sidebar

Related Questions

I really don't get why this is not working. I want to avoid a
I have a homework problem that I really don't know how to start. Here
This is one of things that I really don't get. I know that it's
Ok guys I'm really at a dead end here, don't know what else to
I really don't get why this isn't working, so please help. I'm trying to
I really don't know if it's a Netbeans issue but here's the problem: In
I really don't know what's going on here, I've been racking my brain for
I really don't know, what the Problem is? I get the following error: File
I really don't know where the fault is all about. Here is my code:
I really don't know how to explain what's going on, so I'll just show

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.