Android :: Sending Broadcast Intent From Runnable
Jul 10, 2010I want to send a broadcast from a new thread is start.
This is what i tried:
CODE:............
But ofcourse i need context..this won't work. How can i handle this.
I want to send a broadcast from a new thread is start.
This is what i tried:
CODE:............
But ofcourse i need context..this won't work. How can i handle this.
I'm building a service that sends a broadcast intent when some value changes. The service sends the broadcast like this:
Intent broadcastIntent = new Intent(); broadcastIntent.setAction("nl.vu.contextframework.NEWREADING"); broadcastIntent.setData(Uri.parse("context://"+cer.getKey())); broadcastIntent.putExtra("reading",cer); broadcastIntent.addCategory("nl.vu.contextframework.CONTEXT"); sendBroadcast(broadcastIntent);
In some Activity (in a different process), I'm tryint to receive this broadcast as follows:
IntentFilter intentFilter = new IntentFilter();
intentFilter.addDataScheme("context");
intentFilter.addCategory(CATEGORY_CONTEXT);
registerReceiver(new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
Log.d(TAG,"Received intent "+intent); }
}, intentFilter);
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.
Do any one know how to broadcast any intent if new email is received?
View 8 Replies View RelatedI'm trying to start an activity out of a widget so I can't use the startActivity() function. So I'm trying to create the correct intent but I don't find what I'm missing.
View 2 Replies View RelatedIn the examples, they create Intent as:
Intent intent = new Intent(this, AlarmReceiver.class);
But suppose my AlarmReceiver class is in another app, how do I create this intent?
I've tried with
new Intent("com.app.AlarmReceiver")
but nothing happens.. It was not called..
--Broadcast definition added using the manifest editor on Eclipse:
CODE:.................
Is it possible to broadcast an Intent from native code? If so, is there documentation and/or sample code pertaining to the relevant APIs?
View 1 Replies View RelatedI 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?
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.
View 1 Replies View RelatedI'm working on a project where I need to run the BroadcastReceiver for a third party library for a specific Intent. I also want to run some of my own code when the Intent is broadcast. If I supply my own BroadcastReceiver for the same Intent, it seems that only, one or the other runs, but not both, depending on which appears first in the AndroidManifest.xml file. Is it possible to register multiple BroadcastReceivers for the same Intent in the same application and have them all run? AndroidManifest.xml snippet
View 4 Replies View RelatedDoes Android broadcast an intent when the network state has changend, i.e. from GSM to Wifi? And if so what permission do I need and what is the intent action called?
View 3 Replies View RelatedIs there a way to capture a key event from the Menu button using an Intent or Broadcast Receiver? Basically I want my app's Service to be activated when the Menu key is pressed.
View 1 Replies View RelatedIs it possible to listen for entries to the log?
Ie is there a broadcast intent for when a log entry is appended?
I am adding some basic alarm functionality to my program via the use of AlarmManager and a BroadcastReceiver class (named AReceiver.java). My problem is that the data I add to the bundle attached to the Intent creating the PendingIntent appears to be lost. The only bundle data I can access in the AReceiver class is a android.intent.extra.ALARM_COUNT=1. Here is the basic code in the main activity class creating the Intent, PendingIntent and the AlarmManager: [Code in main activity - Notepadv3]
Intent intent = new Intent(Notepadv3.this, AReceiver.class);
intent.putExtra("teststring","hello, passed string in Extra");
PendingIntent alarmIntent = PendingIntent.getBroadcast(this, pendingPeriodIntentId, intent, 0);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, timeOfNextPeriod.getTimeInMillis(), alarmIntent);..................
I want send LinkedHashMap to another Intent.
But I don't known what method for extras is allowable.
CODE:...................
From a service that's running, how do I send an event or an intent to an app widget that is just sitting their idle.
View 6 Replies View RelatedI added broadcast listener "BATTERY_CHANGED" to Android Manifest file so that when the status changed I should get informed. I am adding to Android Manifest file as I want it active through my application life time. But the problem is that I am not getting the broad cast event from the system when battery status changes.
My code is here :-
<receiver android:name=".MyBroadcastReceiver" android:enabled="true"
android:permission="android.permission.BROADCAST_STICKY">
<intent-filter>
<action android:name="android.intent.action.BATTERY_CHANGED" />
</intent-filter> </receiver>
<uses-permission android:name="android.permission.BATTERY_STATS"/>
<uses-permission android:name="android.permission.BROADCAST_STICKY"/>
I am new to android. I what to know the difference between Intent and Broadcast Receiver. I am more confused with Broadcast receiver then Intent. Simple codes will be helpful.
View 1 Replies View RelatedIs is possible to send an object to an Android Service through an Intent without actually binding to the service? Or maybe another way for the Service to access Objects...
View 2 Replies View RelatedI want to send an intent from a crash handler [ crash(String tag, Throwable t) in RuntimeInit.java) ] to an activity (stand alone appllication)
I tried to send it from above handler as follows..
CODE:................................
But i failed to send an intent to my application..
Can i send an intent to my application fro RuntimeInit.java handlers?
I have created an app that sends an email with a recording, When the intent is fired and email is chosen as the app to send the attachment, you can see that there is an attachement but the attachment is not delivered. code...
View 1 Replies View RelatedIs their a way to put a POJO inside the intent.putExtra? I have looked into the API's and it only seems to support of type string, int, double, boolean etc. But not a actual POJO / regular Java object.
View 1 Replies View RelatedI'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 RelatedI'm having hard times getting my GL thread (from GLSurfaceView) to trigger some code execution within the UI thread (from Activity). I tried it in every possible way (well not every, I missed at least the good one) none worked.
My idea was to get something called from the UI thread (to update some widgets) when the surface is effectively created. So I added to my onSurfaceCreated method the following call:
CODE:.............
This compiles, but when my GLSurfaceView sub-class is constructed a NoClassDefFound exception is thrown, telling me that the class com.my.package.MyGLSurfaceView$1 is not found.
Here's the log:
CODE:.............
The line 297 in MySurfaceView.java is:
private Runnable mUpdater = new Runable () { public void run () { [...] } };
I didn't found clear answer for why my code does not work. I assume it is because I am trying to update textview from runnable. Anybody know some workaround? Code isn't clean off course, I am happy to get that working so far as I am totally new in java.
CODE:...............................
In an existing Android project I've encountered the following piece of code (where I inserted the debugging litter) code...
with not a trace of the messages from the Runnable. So appearantly the Runnable doesn't run(), although img.post() returns true. Pulling the ImageView in onCreate() and declaring it final doesn't help.
I'm clueless. Simply setting the bitmap directly, while blocking the UI thread, does fix things, but I want to get things right. Does anybody understand what's going on here?
(ps. this was all observed on an Android 1.6 phone and android-3 sdk)
I developed one small application to display some text at defined intervals in the android emulator screen.I am using Handler class, small snippet from my code...
When i run this appication the text is displayed only one time.Please any one knows how to run a thread using Handler.
I have looked at every discussion and thread I can find on getting this to work but it is not. I have a simple timer that updates a text view (mTimeTextField in the example below). The mUpdateTimeTask run method is being executed correctly (every second) but the UI/text field is not being updated.
Here is the code:....................
I'm trying to do an insert to a DB as a result of a user clicking on a button. I want to do the actual insert in the background, so it seems I should use a Handler to do this. The SQLite insert method takes a Context parameter. My problem is how do I get a valid Context inside the Runnable that will do the insert?
View 4 Replies View Relatedtrying 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