broadcastreceiver

How to detect incoming call with the help of Broadcast Receiver?

冷暖自知 提交于 2019-12-02 05:17:26
问题 I'm trying to recognize incoming calls in thru a broadcast receiver. I'm UNABLE to do so! Infact, I'm unable to 'trigger' the broadcast! Here's my code: activate.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getApplicationContext(),"Clicked",1).show(); final String BROADCAST_ACTION_NAME = ".BroadcastMM"; Intent intent = new Intent(); intent.setAction(BROADCAST_ACTION_NAME); sendBroadcast(intent); } } I dunno if this 'sendBroadcast' is ever

BroadcastReceiver behavior when phone is asleep

匆匆过客 提交于 2019-12-02 05:09:31
I am not quite certain what the behavior of a BroadcastReceiver , registered in the manifest and enabled via PackageManager , is when the phone is asleep. The question arose because I need a receiver registered for broadcasts from WifiManager <receiver android:name=".receivers.ScanResultsReceiver" android:enabled="false" > <intent-filter> <action android:name="android.net.wifi.SCAN_RESULTS" /> <action android:name="android.net.wifi.WIFI_STATE_CHANGED" /> </intent-filter> </receiver> but what I want to know (as in links to the docs or some authoritative post in google groups) is which

Android BroadcastReceiver won't register

左心房为你撑大大i 提交于 2019-12-02 05:07:44
问题 I'm trying to add a simple broadcast receiver to my audio application, so that I can mute everything when the user clicks their ACTION_MEDIA_BUTTON on their headset. I've read that you can either register it in the manifest, or dynamically in the code. I have gone down the path of registering it in the code, as I need to call methods within my main activity class to react to the media button press. For some reason however, my BroadcastReceiver just will not register, and I can't find anything

android register a permanent Broadcast Receiver

让人想犯罪 __ 提交于 2019-12-02 04:57:38
I need to create a BroadcastReceiver which performs certain task immediately each time the device boots up. Also, when a certain button is clicked, the receiver should stop starting on boot. Can someone help me to manage that? All you need to solve the first part of your question is to make a BroadcastReceiver for it and declare it in your Manifest as: <receiver android:name=".MyBootReceiver" android:enabled="true" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.QUICKBOOT_POWERON" /> </intent-filter> </receiver> The

BroadcastReceiver does not receive Broadcast from IntentService

倾然丶 夕夏残阳落幕 提交于 2019-12-02 04:37:58
I'm trying to send a broadcast from an IntentService to the activity that started it, this is how i register the Receiver in the activity: private BroadcastReceiver mInitializer; @Override protected void onCreate(Bundle savedInstanceState) { .... mInitializer = new InitializationReceiver(); IntentFilter initializer = new IntentFilter(); initializer.addAction(IntentConstants.Tasks.INITIALIZE); initializer.addAction(IntentConstants.Initialization.INITIALIZE_IS_FIRST_START); initializer.addAction("test"); registerReceiver(mInitializer, initializer); .... } private class InitializationReceiver

unable to run service when Date changes using broadcast receiver

老子叫甜甜 提交于 2019-12-02 04:19:54
I create an birthday reminder app. I want to start service at 12:00 in night to scan birthdays of person in Database. I add a broadcast receiver. <receiver android:name=".MyReceiver"> <intent-filter> <action android:name="android.intent.action.DATE_CHANGED"/> </intent-filter> </receiver> But It don't work. I don't why.. here is the code of broadcast receiver ..... package com.example.forgetmenot; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast; public class MyReceiver extends BroadcastReceiver { @Override

BOOT_COMPLETED never received

拥有回忆 提交于 2019-12-02 04:06:40
问题 Does every device send the BOOT_COMPLETED? I want to start an Activity on Boot Completed. I put the following in the Manifest: <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <receiver android:name=".BootFinished"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> Created the following class (receiver): import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent;

GCM push notification for background app causes crash

馋奶兔 提交于 2019-12-02 03:56:19
I stumbled about a problem to receive GCM messages if my app runs in background (Service). In my scenario, I don't receive the GCM message (please notice it is not about how to receive GCM in general like here ) and the ActivityManager kills the app. So I wonder if I have a conceptual misunderstanding or if it is a general problem. Background I have an Android application that runs in foreground (Activity) and background (Service). The application is attached to a persistent notification to make sure that the app continues to run even if the user opens the Android TaskManager and swipes the

Launch application using dial pad in android

二次信任 提交于 2019-12-02 03:34:43
问题 I want to launch my application through dial pad.I am using the following code. For dial pad to launch application (in Broadcast receiver) public class HiddenReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { try{ // Toast.makeText(context,"Number Dialed",1).show(); Intent serviceIntent = new Intent(context,MainActivity.class); serviceIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(serviceIntent); } catch(Exception e) {

Why does ACTION_MEDIA_BUTTON fail to process events?

为君一笑 提交于 2019-12-02 03:21:29
Following the training section on how to use hardware playback control keys to control audio playback , I create a listener class: public class RemoteControlReceiver extends BroadcastReceiver { @Override public void onReceive(Context arg0, Intent intent) { if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) { KeyEvent event = (KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); Log.e(TAG, "ACTION_MEDIA_BUTTON"); int keycode = event.getKeyCode(); switch (keycode) { case KeyEvent.KEYCODE_MEDIA_NEXT: Log.e(TAG, "KEYCODE_MEDIA_NEXT"); break; case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: