---
title: "Wake lock required for BroadcastReceiver phone sleeps?"  
description: "Wake lock required for BroadcastReceiver phone sleeps?"  
author: "Anonymous User"  
published: 2014-11-18  
updated: 2014-11-19  
canonical: https://www.mindstick.com/forum/12636/wake-lock-required-for-broadcastreceiver-phone-sleeps  
category: "android"  
tags: ["android sdk"]  
reading_time: 1 minute  

---

# Wake lock required for BroadcastReceiver phone sleeps?

[Trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to write a [Broadcast Receiver](https://answers.mindstick.com/qa/40997/give-an-example-where-you-can-use-broadcast-receiver) that processes incoming SMSs. Do I need to use a wake [lock](https://www.mindstick.com/interview/319/what-is-lock-escalation) / [partial](https://www.mindstick.com/blog/78/partial-class-in-dot-net) wake lock, for this [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) to work, in spite of [device](https://www.mindstick.com/blog/149/retriving-network-device-information-in-c-sharp) [going to sleep](https://yourviews.mindstick.com/story/4050/benefits-of-going-to-sleep-with-empty-stomach) due to lack of foreground [activity](https://www.mindstick.com/forum/12894/how-to-force-recreation-of-activity-fragment-on-restore) ?

## Replies

### Reply by Anonymous User

I tend to extend a WakefulBroadcastReceiver to simplify things, so in a way yes. For example:

```
public class MyBroadcastReceiver extends WakefulBroadcastReceiver
{    @Override    public void onReceive(Context context, Intent intent) {        final ComponentName comp = new ComponentName(context.getPackageName(),                MyIntentService.class.getName());        // Start the service, keeping the device awake while it is launching.       
startWakefulService(context, (intent.setComponent(comp)));        setResultCode(Activity.RESULT_OK);    }}
```


---

Original Source: https://www.mindstick.com/forum/12636/wake-lock-required-for-broadcastreceiver-phone-sleeps

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
