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 8756799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:09:30+00:00 2026-06-13T14:09:30+00:00

if my mobile is in screenlock, the GCMBroadcast receiver doesn’t send the message to

  • 0

if my mobile is in screenlock, the GCMBroadcast receiver doesn’t send the message to the GCMIntentService.
I’ve read that the solution is to implement the trick of wakelock.acquire() and wakelock.release() in the onReceive method of my broadcast receiver.
BUT the GCMBroadcastReceiver has the onReceive in final, so i can’t add, this feature.

Is there a solution?

[EDIT]

Wrong Question, after 5 hours of investigation, i’ve solved everything.

To clarify:

  • GCMBroadcast has the wakelock acquire and release, no needed any
    implementation.
  • My problem was due to the DELAY WHEN IDLE property set as true in the SERVER CODE.

    builder = builder.delayWhileIdle(true);
    

From official documentation:

if the device is connected but idle, the message will still be
delivered right away unless the delay_while_idle flag is set to true.
Otherwise, it will be stored in the GCM servers until the device is
awake.

[/EDIT]

here my code:
GCMIntentService

public class GCMIntentService extends GCMBaseIntentService{

public GCMIntentService() {
    super(CommonStuff.SENDERID);
    // TODO Auto-generated constructor stub
}


@Override
protected void onError(Context arg0, String arg1) {
    // TODO Auto-generated method stub
    System.out.println("onError:"+arg1);
}

@Override
protected void onMessage(Context context, Intent intent) {

    Log.i("GCMIntentService", "Message Received");

    Bundle extras = intent.getExtras();

    // Extract the payload from the message

    if (extras != null) {


        String type=(String)extras.get("type");
        String msg=(String)extras.get("message");
        //do something........

    }

}

@Override
protected void onRegistered(Context ctx, String regId) {
    Log.d("GCMIntentService","REGID_ARRIVED:"+regId);
    try {
        //do something
    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

}

@Override
protected void onUnregistered(Context arg0, String arg1) {
    // TODO Auto-generated method stub
    System.out.println("onUnregistered:"+arg1);

}

}

the wakeLocker

public abstract class WakeLocker {
private static PowerManager.WakeLock wakeLock;

public static void acquire(Context ctx) {
    if (wakeLock != null) wakeLock.release();

    PowerManager pm = (PowerManager) ctx.getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK |
            PowerManager.ACQUIRE_CAUSES_WAKEUP |
            PowerManager.ON_AFTER_RELEASE, MainActivity.APP_TAG);
    wakeLock.acquire();
}

public static void release() {
    if (wakeLock != null) wakeLock.release(); wakeLock = null;
}
}

my GCMreceiver in MANIFEST

<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="my.app.package" />
            </intent-filter>
        </receiver>
  • 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-13T14:09:32+00:00Added an answer on June 13, 2026 at 2:09 pm

    Just to set as solved, the solution in the edit part of question.

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

Sidebar

Related Questions

A mobile application that I'm working on is expanding in scope. The client would
I have a jQuery Mobile app, that loads pages in via ajax eg page1.html,
In mobile web minibrowsers, it seems that the window object makes no sense —
Mobile Safari on iPad is supposed to be HTML5-compliant, but it seems that the
Windows Mobile 6.x is based on Windows CE 5.x and it doesn't have CDFS
Windows Mobile 6.0 devices have a Text Size setting that can be reached by
My mobile's(screen) is 1280X720. From parameters.getSupportedPreviewSizes() , there does not exist one size that
Mobile devices/tablets have usb ports so is there a way to send the print
I've included a mobile web form in my asp.net project, I thought that it
For mobile apps, I know that they can be written in Java for Android

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.