broadcastreceiver

Handle Google C2DM intents in a service?

痴心易碎 提交于 2019-12-12 03:06:37
问题 If I set up my Android Manifest XML file correctly, can I handle C2DM intents (REGISTRATION and RECEIVE) in a regular service, rather than a broadcast receiver? Clearly, the application would need to be designed for this, but I'm just curious if it's possible or if something is limiting the C2DM intents to a broadcast receiver, as every example I've read online uses a broadcast receiver, but it seems to me one could use a service as well. 回答1: Quote from Google: An application on an Android

Battery is draining because of alarmManager and Broadcast Receiver I think

流过昼夜 提交于 2019-12-12 02:22:09
问题 HI i have an app like a applock (not applock) , which checks for current app running with list of selected apps by a user , if it matches then I hv my code . I have an service which doesnt have any loops calls StartupReceiver .Class(broadcast Receiver) which inturn calls CheckRunningApplicationReceiver.Class(broadcastReceiver) which checks the current activity . I am calling CheckActivity for every 0.5 second . And i do lot of storing and retrieving strings in internal storage inside the

Why can't we call StopForeground() method in the broadcast receiver class?

ぐ巨炮叔叔 提交于 2019-12-12 02:09:21
问题 I have a broadcast receiver class and when I receive a particular broadcast I would like to stop the foreground notification. So I tried context.stopForeground() but the intellisense did not show the method. How can we call the stopForeground() method in the broadcast receiver class ? public class Broad extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if(intent.getAction()==Const.ACTION_STOP) { // unable to call like this context.stopForeground();

Way to ensure delivery of Action HEADSET_PLUG for ZTE T815 Android phone

*爱你&永不变心* 提交于 2019-12-12 02:02:55
问题 I have registered a BroadcastReceiver to receive ACTION_HEADSET_PLUG which works fine for most devices, ie it is called whenever the headset is plugged or unplugged. But on others eg the ZTE T815, the Intent is never sent/received when the headset is plugged/unplugged. For reference here is the code for the receiver registration: private final BroadcastReceiver headsetPlugReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG,

Running an IntentService in BroadcastReceiver using AlarmManager

◇◆丶佛笑我妖孽 提交于 2019-12-12 01:38:47
问题 I want to call a Service in my Receiver class which extends BroadcastReceiver but the service didn't start and I got this error: FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start receiver com.example.ahmed.service.AlarmReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference In my MainActivity, I call the alarm manager: // Calendar settings for AlarmReceiver Calendar cur

how to listen for a call disconnect on android?

狂风中的少年 提交于 2019-12-12 01:35:55
问题 I'm trying to figure out how to be notified when a call is disconnected - both incoming and outgoing. the intent is to launch something on call disconnect. I looked at the telephnyManager page and i can see getCallState(), but looking at all the constants, i don't see anything like what i'm looking. I'm guessing i need to set up a broadcast receiver - i'm just not sure what i'm listening to... Thanks for helping!! 回答1: Please try this link it have some documentation regarding android

Android - How to immediately endCall with telephonyService?

女生的网名这么多〃 提交于 2019-12-12 01:34:13
问题 In my application, there's a feature that ends outgoing call (and starts other activities) while dialing a certain number (e.g. *123* ) It's currently working, but requires a 200ms delay. Without the delay, the intent cannot be recieved. The delay causes a consequence of multiple screen flickers: my activity shows -> switch to call -> end call -> switch back to my activity public class OutgoingCallListener extends BroadcastReceiver { // ... public void onReceive(final Context context, Intent

Android sms receiver doesnt work

天大地大妈咪最大 提交于 2019-12-12 00:22:41
问题 I've searched a lot on web and on SO I couldn't find an answer to my case or a straightforward tutorial, I was following this my problem is that the constructor doesn't get call nor onReceive(). public class Smsreceiver extends BroadcastReceiver { public Smsreceiver() { Log.v("constructing", "constructing"); } @Override public void onReceive(Context context, Intent intent) { Log.v("received", "received"); Bundle bundle = intent.getExtras(); SmsMessage[] msgs = null; String str = ""; if

start activity even when phone is locked

此生再无相见时 提交于 2019-12-12 00:17:47
问题 I would like to start an activity like the one used when an alarm starts ringing and a dialog dismiss appears even when the phone is locked and I am able to click it. I have this code from this site but I don't know how to call it when I extend using broadcastreceiver. It always says the method getWindow() is undefined type for... I always seemed to get this error everytime I code, what does that mean. public void unlockScreen() { Window window = getWindow(); window.addFlags(WindowManager

Android broadcast receiver for PHONE_STATE is not working

会有一股神秘感。 提交于 2019-12-11 23:27:15
问题 hello friends i am working on android broadcast receiver but it is not working. My code for broadcast receiver is given below. public class MainActivity extends BroadcastReceiver { @Override public void onReceive(Context arg0, Intent arg1){ Toast.makeText(arg0, "Service Explicitely", Toast.LENGTH_SHORT).show(); arg0.stopService(new Intent(arg0,CallRecordingService.class)); Intent intent=new Intent(arg0, CallRecordingService.class); arg0.startService(intent); Toast.makeText(arg0, "Service