broadcastreceiver

BroadcastReceiver within a Service not receiving broadcasts Android

雨燕双飞 提交于 2019-11-29 14:41:28
I've got this app, in which users update certain variables in an Activity, and this Activity passes the new variables to a IntentService using a BroadcastReceiver. However, the BroadcastReceiver in the IntentService doesn't seem to be receiving the broadcasts. This is the code within the service to create the broadcast receiver protected class UpdateReceiver extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent){ Log.d("receiver", "Got message: "); //state=3; //Toast.makeText(context, "got it", Toast.LENGTH_SHORT).show(); } }; And here's the code to register

Starting and stopping a notification from broadcast receiver

守給你的承諾、 提交于 2019-11-29 14:41:05
问题 I'm trying to start a status bar notification from a broadcast receiver and then stop it from another broadcast receiver but I'm having issues. I would like to start the notification in the status bar when usb is connected and then when usb is disconnected I would like to stop it I have the two receivers set up and working just struggling with starting and stopping one from a receiver here is the code I have currently My only error with my code is the myNotificationManager =

Android-Broadcast Receiver and Intent Filter

与世无争的帅哥 提交于 2019-11-29 14:35:22
问题 I am new to android platform.please help me out how the Broadcast Receiver and Intent Filter behaves in android.please explain in simple line or with example.thanks in advance... 回答1: A broadcast receiver is a class in your Android project which is responsible to receive all intents, which are sent by other activities by using android.content.ContextWreapper.sendBroadcast(Intent intent) In the manifest file of you receicving activity, you have to declare which is your broadcast receiver class

Android - Registering a broadcast receiver for two intents?

ε祈祈猫儿з 提交于 2019-11-29 14:31:57
问题 I was wondering is it possible to register a broadcast receiver to receive two intents? My code is as follows: sipRegistrationListener = new BroadcastReceiver(){ @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (SIPEngine.SIP_REGISTERED_INTENT.equals(action)){ Log.d("SETTINGS ", "Got REGISTERED action"); } if (SIPEngine.SIP_UNREGISTERED_INTENT.equals(action)){ Log.d("SETTINGS ", "Got UNREGISTERED action"); } } }; context.registerReceiver

Volume change Listener: Is registerMediaButtonEventReceiver preferable to onKeyDown?

和自甴很熟 提交于 2019-11-29 14:28:59
问题 Looking for a "most comprehensive & compatible (i.e. all Android versions...)" way to listen to volume changes, I found 2 different approaches to handle this: registerMediaButtonEventReceiver onKeyDown + SettingsContentObserver Which method is preferable? And why? UPDATE 1: Thanks to the comment below, I discovered that onKeyDown() actually takes over the volume key, which may not be a complete solution as one of the posts mentioned that volume could be changed via interfaces other than the

Battery broadcast receiver declared in manifest file does not work?

半城伤御伤魂 提交于 2019-11-29 14:23:50
There are two ways to make a broadcast receiver known to the system: One declares it in the manifest file with this element. The other is to create the receiver dynamically in java code. Now, the receiver has been created dynamically in java code and it does work normally.But why the first way "Declare in the manifest file" failed? Is there anyone to success? Thanks. AndroidManifest.xml <receiver android:name="pj.batteryinfo.BatteryReceiver"> <intent-filter> <action android:name="android.intent.action.BATTERY_CHANGED"></action> </intent-filter> </receiver> For some actions, you could only

Android - How to use a local broadcast receiver?

[亡魂溺海] 提交于 2019-11-29 14:19:38
I'm trying to use a local broadcast receiver. In order to do so I"ve done the next steps - 1) At an Activity, where Iwould like something to happen, I've created a class - private class NewGroupReceiver extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { Log.d("The group ", "GOT IN THE RECIVING"); Toast.makeText(this, "Working",Toast.LENGTH_SHORT).show(); } } 2) At the same activity I've used the next code in order to create a receiver - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); NewGroupReceiver

BroadcastReceivers in ICS

扶醉桌前 提交于 2019-11-29 14:17:03
I had written a small utility app just for my phone, which stopped the annoying carrier provided jingle which played on boot up. I noticed the sound didn't play if I put the phone into silent mode before powering off, so I wrote this little utility to go silent on power down and restore sound on boot. This worked well for a Galaxy S2 on Gingerbread. The entire code is in two classes: public class OnShutDownReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { AudioManager mgr=(AudioManager)context.getSystemService(Context.AUDIO_SERVICE); mgr

How to determine the sender of Broadcast Intent

左心房为你撑大大i 提交于 2019-11-29 14:00:47
I have an application that is at the same time a broadcast sender and receiver of standard action android.intent.action.SET_WALLPAPER. I want to do some stuff only in a case when another application broadcasted this intent. Is there any way to determine who initiated a broadcast in onReceive method of a BroadcastReceiver? No. If you only want to do something when an action was broadcast by another app (i.e. not yours), I imagine it should be easy to determine that your app didn't send this broadcast, and therefore it was someone else.. If all you care about is if it was sent by your app or not

Communicate between different instances of same fragment

情到浓时终转凉″ 提交于 2019-11-29 13:54:25
The problem as follows. Let us have 3 tabs with fragments: Tab 1 (Fragment A). Needs to send data to Tab 2. Tab 2 (Fragment B). Needs to receive data from Tab 1. Tab 3 (Fragment B). Already contains data. As you see Tab 3 and Tab 2 contain the same Fragment but different instances. How do I send data (not via arguments) to exactly Tab 2? What I've tried: Set the unique ID for Fragment B via arguments when they were created. Register same Local Broadcast Receiver for both instances of Fragment B Send data from Fragment A to Fragment B with its ID In Fragment B onReceive() check if recevied ID