Android :: ACTION_HEADSET_PLUG Broadcast ?

Mar 26, 2010

I've tried these phones: Motorolla Backflip 1.5, Nexus One 2.1

Basically I register BroadcastReceiver to get ACTION_HEADSET_PLUG broadcast and look on 3 extras that come in intent:

state
name
microphone

Here is the description from API:

* state - 0 for unplugged, 1 for plugged.
* name - Headset type, human readable string
* microphone - 1 if headset has a microphone, 0 otherwise

Issue #1: Broadcast comes when activity is started (not expected), when screen rotation happens (not expected) and when headset/headphones plugged/unplugged (expected).

Issue #2: Backflip phone (1.5) sends null for state + microphone, 'No Device' as name when headset/headphones unplugged, and sends null for state + microphone, 'Stereo HeadSet'/'Stereo HeadPhones' as name when headset/headphones plugged.

UPDATE: T-Mobile G1 with 1.6 behaves the same as Backflip phone.

Nexus even worse, it always sends null for state + microphone, 'Headset' as name when headset/headphones plugged or unplugged.

Question: How it can be explained that API is broken so much on both 1.5 and 2.1 versions and different devices, manufactures?

UPDATE:

Code in onCreate of main Activity:

CODE:.........................

Now the code of BroadcastReceiver:

CODE:................................

Android :: ACTION_HEADSET_PLUG broadcast ?


Android :: ACTION_HEADSET_PLUG Broadcast Delay

Nov 8, 2010

I have my own BroadcastReceiver instance for Intent.ACTION_HEADSET_PLUG action.

There is about 1-2 seconds delay between actual physical unplugging a headset and a moment when my BroadcastReceiver is notified about that.

CODE:........................

How to decrease the delay?

View 2 Replies View Related

Android :: Is This Systems Broadcast Ordered Or Normal Broadcast?

Aug 13, 2010

I'm trying to figure out if a system event broadcast is broadcasted using ordered broadcast or normal.The event is EVENT_REMINDER and in the source for the calendarprovider i noticed it sets up a alarmmanager to sent the broadcast. I can't find how the alarmmanager sends it. My guess would be as a normal broadcast , But while i was trying some things i noticed i could delay the system's notification (tried up to 10 sec) by building a sleep in my broadcastreceiver. This would indicate that they are handled ordered , and the systems receiver is only called when mine has finished. But can i be sure of this behavour?? (in all 1.5> sdk versions) the docs state that in some cases normal broadcasts are also handled ordered..due to spare of resources.

View 1 Replies View Related

Android :: Broadcast Receiver - Create A Broadcast Receiver Which Responds To System Events

Sep 28, 2009

trying to create a broadcast receiver which responds to system events and change system settings. I don't need any interaction from the user so I don't need an activity and have been trying to do everything through the manifest file. I've put a log event into my onReceive method but it never logs anything so I'm presuming my method is never called. I've tried this with both the 1.5 and 1.6 SDKs. I was hoping somebody could have a look at my code please and let me know if there are any problems.

View 2 Replies View Related

Android :: Multiple Broadcast Messages With Less Data Or Less Broadcast Messages With More Data

Oct 5, 2009

I am developing an application which is communicating with the server. Tha application can perform log-in and get different parameters from server.

The application consists of a RESTful client (custom class for making requests), Communication Service (the service which runs in the background) and the main activity.

For now I created multiple broadcast messages and multiple broadcast receivers in the main activity so when the application performs login operation a receiver (loginBroadcastReceiver) in the main activity receives a message and when another parameter is received from the server different message is broadcasted and another receiver handles the message.

This way however the application performance is poor but I am not sure whether it is due to multiple broadcast receivers.

Does anyone know what is the best way to exchange data between service and main activity - is it better to create a single broadcast receiver and retrieve all parameters from message or is it better to initialize multiple broadcast receivers for multiple parameters?

View 1 Replies View Related

Android :: How Different Do Broadcast Intents Need To Be?

Oct 30, 2010

I have an IntentService that broadcasts an Intent each time if finishes some work. Each broadcast Intent is identical except that it contains a Bundle with some result information from the IntentService. Evidently, having different data in the Bundle is not enough for Android to think it's a different Intent. If the IntentService broadcasts two of these Intents back-to-back, the second one is dropped as a duplicate.

I know I've read about this behavior in this forum in the past but I can't find in the documentation where this duplicate elimination logic is described in detail. Mostly, I just want to differentiate the Intents enough that they are not considered duplicates. Any pointers would be appreciated.

View 13 Replies View Related

Android :: HTC EVO Can't See UDP Broadcast Packets?

Jul 19, 2010

I'm pretty sure no one but me is using UDP broadcasts but in the rare chance that someone is - has any experienced this? I use UDP broadcast to do LAN multiplayer games - it's how clients discover hosts of games.The EVO can't ever see the games when all my other phones can.

View 4 Replies View Related

Android :: Using Broadcast Receivers

Sep 9, 2009

I had one question: Is it feasible to use a BroadcastReceiver as a glue layer between the user interface and the underlying business logic ? Example use case: Suppose i am maintaining the state of a call, and providing callbacks to the UI by invoking sendBroadcast with the relevant intent. Similarly, my underlying business logic can send broadcasts to the activity that has registered for receiving it on certain events ( like call connected, connecting, timed out etc).

View 4 Replies View Related

Android :: How To Use Broadcast Receivers?

Dec 30, 2009

Is it possible to use just a broadcast receiver without any activities? I just want to run some sample code only when the phone receives a call and nothing more. I use Log.d to write out but I don't see anything in the log. Am I missing something here? I also have permissions set in the androidmanifest.xml to allow for these type of intents.

View 3 Replies View Related

Android :: Notification / Broadcast For Sent Sms

Jul 1, 2010

is there any way to be notified (using a broadcast receiver) after a sms is sent? i want to get notified when a sms is sent and carry on with my program.

View 7 Replies View Related

Android :: IP Broadcast On Emulator

Oct 15, 2009

I have an application that acts as both client and server. I have a scenario that I need to test that involves three devices. One of them needs to broadcast a message (UDP) to the other two. Running on physical devices, this is not a problem, and it works fine. On the emulator however, this is much harder. I have managed to get it work for two devices using the emulator. Here my client thread broadcast the message to 10.0.2.255 port 6002, and server thread listens on port 6006. By using redir add udp:6002:6006 the server receives the message fine. Now, if I add another instance and do the same portforwarding, only one of them receives the message. I also tried to use a different port number on the server, and forward port 6002 to that number, with the same result. It appears as if a port can only be forwarded from one instance. Does anyone of a method to broadcast using the emulator, without sending a separate message to each emulator instance?

View 4 Replies View Related

Android :: Start TTS From Broadcast Receiver

Jul 9, 2009

I am trying to start TTS from a broadcast receiver and it as document an intent receiver can't bind the service. Is there a work around, I can't figure out how to start the service using startService(Intent, Bundle).

View 4 Replies View Related

Android :: Broadcast Receiver Without Activity

Feb 12, 2010

A WAP PUSH (Broadcast)receiver basically doesn't need any UI. It is a silence application which handles the Push messages based on actions/ mimetype without needing any intreaction with user, I've tried to test it in a SMS receiver by removing the Activity from the project and it stopped receiving the SMS messages. My question: Does all android applications "MUST" define a activity? Is there a way to hide it?

View 5 Replies View Related

Android :: Broadcast Receiver Error

Jul 23, 2010

I am working on one project where i am using broadcast receiver in one of my activity to capture the incomming call and its works fine. when one of my other activity is open and that time if call is come then my broadcast receiver is fail to respond. can any one help me for this ? or its nessesorry to declare broadcast receiver in all my activity to do some comman task.

View 5 Replies View Related

Android :: Broadcast Receiver From Widget

Dec 2, 2009

I am making a widget that needs a broadcast receiver, like the one in com.example.android.apis.appwidget.ExampleBroadcastReceiver. However, the example defines Intent.ACTION_TIMEZONE_CHANGED in the manifest, but there are some that do not allow this. For example, Intent.ACTION_TIME_TICK says "You can not receive this through components declared in manifests, only by exlicitly registering for it with Context.registerReceiver(). "

So I removed the manifest declarations and tried replacing the AppWidgetProvider.onEnabled function that was in the example with a call like the following: context.registerReceiver(myReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
(where "myReceiver" is an instance of the receiver I want.) However, when I try to run the code, I get the following error:
Unable to start receiver...android.content.ReceiverCallNotAllowedException: IntentReceiver components are not allowed to register to receive intents.
Any way to get this broadcast receiver working from a widget?

View 3 Replies View Related

Android :: Any Other Application As Broadcast Receiver?

Jul 29, 2009

I am broadcasting an Intent from an activity. Can we make another application as a receiver. So that it will get invoked when that specific intent is broadcasted.

View 2 Replies View Related

Android :: Broadcast Receiver Sometimes Works

Jan 6, 2010

I wish to listen to android.intent.action.BOOT_COMPLETED. However I am not getting the broadcast intent, if I specify com.test.BootBroadcastReceiver in the manifest. When I change this value to simply BootBroadcastReceiver, then I am getting the broadcast intent.

<receiver android:name="BootBroadcastReceiver" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

My package in the manifest file is:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test"
And the BootBroadcastReceiver resides in this package. What is the reason behind this?

View 2 Replies View Related

Android :: Trying To Understand Use Of Broadcast Receiver

Aug 17, 2009

I have an application that uses an extended Broadcast Receiver class inside the Activity. I have the extended Broadcast Receiver class as a member variable of the Activity class. But it looks like the receiver references keep changing between its construction and 'on Receive' method call. I would like to understand this better. Here are some details. public class MyEventReceiver extends Broadcast Receiver

View 3 Replies View Related

Android :: Broadcast Receiver For Action

Oct 3, 2009

I was wondering if its possible to have a broadcast receiver to listen when the app its in launches.I tried doing by creating a BroadcastReceiver to listen for the android.intent.action.MAIN action but it never gets called?Is there something I need to do or a different action I should be listening for?

View 3 Replies View Related

Android :: How To Use Broadcast Receiver In Different Applications?

May 1, 2010

I have here two applications in two different projects in eclipse. One application

(A) defines an activity

(A1) which is started first. Then i start from this activity the second activity

(B1) in the second project

(B). This works fine.

Unfortunately, the message is never received. Although the method in activity A1 is called, i never receive an intent in B1.

View 1 Replies View Related

Android :: Broadcast Receiver For Sent SMS Messages?

Jun 13, 2009

I created a BroadcastReceiver and configured it with an android.provider.Telephony.SMS_RECEIVED action filter so it is called everytime the phone receives a text.Is there some event/action or other way for my application to be notified whenever the phone sends a text (preferably independent of the application that sends it)?So far the only option I see is to poll the content provider for content://sms/sent which doesn't even give me all sent texts because applications can choose not to put it there.

View 1 Replies View Related

Android :: Dns Failing In Broadcast Receivers?

Mar 16, 2010

something weird just started happening. my app has a broadcast receiver which may access the network when invoked. the code has been solid for ages, but in the last few days it has started getting DNS errors on perfectly fine hosts. these are hosts which can be reached without problems in the main app or from other apps.interestingly i've seen another app get DNS errors too another app with a broadcast receiver.seems to affect all OS versions -- we have 1.5, 1.6, and 2.01 here. i don't have a Nexus to test 2.1, though. are there caveats to doing network inside broadcast receivers? i didn't think so, as ours worked fine until the time change [fx: twilight zone theme]

View 6 Replies View Related

Android :: Set Priority To Broadcast Receiver

Oct 24, 2010

The symptom: I have a broadcast receiver that listen to sms, when a sms is received, i call an activity to display. It works all fine if the screen is on and not locked. But when screen is locked, and as soon as i received the sms, the activity popup for a second then disappeared and I use the code to unlock the screen.

getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);

I think it might be the competitions with phone default sms program (the sms default program shows a notification only). I am wondering is there a way to set priority to broadcast receivers or even the activity that receiver stared, to avoid the conflicts between multiple receivers. or set orders to execute one by one? I have tried to thread.sleep my receiver for a second, still not working.

View 2 Replies View Related

Android :: Contact Change Broadcast

Mar 11, 2009

Is there a broadcast message dispached when a contact is changed or added in Android's native contact book? If not, what would be the most efficient way to check for changes?Secend of all, what would be the most efficient method for sending a file (image) using HTTP POST request?

View 3 Replies View Related

Android :: Will My App Receive A Broadcast If It Is Not Running?

Oct 3, 2010

I have an app that I want to start when people receive a text. Is this possible?

View 3 Replies View Related

Android :: Broadcast Intent For USB Power?

Feb 20, 2010

Is there a Broadcast Intent that gets sent out when the device is plugged in for power? I want to create a BroadcastReceiver to detect the device's plugged in state.

I've looked everywhere in the Developer's resources and reference, but I can't find anything that resembles what I'm trying to do.

View 4 Replies View Related

Android :: App Launch Broadcast Message

Feb 23, 2009

Is there a message for the broadcast receiver about when an app is being launched? if not is there a way to intercept it?

View 2 Replies View Related

Android :: Not Able To Receive Broadcast Message

Jun 4, 2009

I'm trying to receive Android's Broadcast message say MEDIA_SCANNER_FINISHED, but not able to do so. Here is my code snippet:

CODE:..............

View 2 Replies View Related

Android :: RegisterReceiver For Broadcast Only If It's Not Already Registered?

Jan 26, 2010

I have a snippet of code that I'm calling from a service:

CODE:........

What I would like is a way to check and make sure that the registerReceiver isnt already listening before it calls it again. Is this possible?

For example if my snippet of code is in a method, and I call the method 10 times, right now the onReceive method appears to run 10 times.

View 1 Replies View Related

Android :: Broadcast Data To Other Application?

May 15, 2009

I create an application where i get the various data from net (say for example i am getting the temperature information of particular city and another data is the information of stock value of a particular company) now i want to broadcast that various data to all application. I create a registration process for diff application for diff data (EX app A is registrar for temp of city). so application is registrar for particular data will get that data.

How can i broadcast the information to all application which are registrar .

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved