Android :: Dataflow Between BroadcastReceiver ContentProvider And Activity?
Mar 19, 2009
I've developed an application that receives a Broadcast and then launches an Activity, where that Activity queries a ContentProvider which pulls information out of the DNS in real-time.
I'd like to be able to shuffle this so that instead of going:
CODE:.......
It goes:
CODE:.......
i.e. if the query() returns no data I want to miss out launching the activity, and allow the Broadcast message to fall through as normal.
If the query() does return data, I want that Cursor to be supplied to the Activity, so that I don't have to go and query for the data again.
In turn, the Activity has its own UI which the user needs to respond to.
View 2 Replies
Aug 6, 2009
I want to start a project which contains a BroadcastReceiver and an Activity. The BroadcastReceiver doesn't communicate with the activity. But they share a same resource. Can i do it in only one Project (that means, i use only 1 apk to install both BroadcastReceiver and the Activity on my phone), or i have to develope them seperately in 2 projects.
View 3 Replies
View Related
Feb 26, 2009
Is it possible to update a currently running activity from a BroadcastReceiver? I want to update my activity from a BroadcastReceiver that runs alongside it. When I run my app (from Eclipse), my activity starts. When the BroadcastReceiver is triggered, it currently tries to start the activity (with extras in the bundle...this is the important part), but nothing happens, presumably because the activity is already running. So my question is, how do I get the new information to my Activity (or even just tell the activity that there's new information to get if I stick the information in a database)? This seems like it should be fairly straightforward, but I'm clearly missing something.
View 3 Replies
View Related
Jun 22, 2010
I am wondering whether is possible to use a BroadcastReceiver to listen for an Activity being launched. I have no control of the Activity I need to know about as it is from the Android platform.
View 3 Replies
View Related
Oct 28, 2010
While developing an alarm based application, i have stuck in a scenario.
When my alarm is fired, i can receive the event in BroadCastReceiver::onReceive().
Within this function, i want to notify/call a function, which is located on MainActivity.
How to achieve the same?
View 1 Replies
View Related
Aug 18, 2010
I have 2 Activities that need to communicate with each other: ActivityA and ActivityB
Say that ActivityA opens ActivityB. How do I unicast a message from ActivityB to ActivityA without closing ActivityB?
Here's what I tried: setResult() - but the intent will be delivered only when ActivityB closes sendBroadcast() - but this sends the intent to everyone listening to the action.
I only want the action to reach ActivityA since it spawned ActivityB.
I tried having ActivityA registering a BroadCast receiver, but I cannot target that via Intent's SetComponentName(). startActivity() - this brings up ActivityA, which I don't want.
View 1 Replies
View Related
Jul 18, 2010
When i have a broadcastReceiver say android.intent.action.MEDIA_BUTTON and i want to update the current activity's UI without creating a new activity, is there any good practice on this one?
What i know (might not be correct)
1) I can put the BroadcastReceiver in the same class as the activity and call the updateUI function after certain activity
2) Create a ContentObserver?
3) Communicate to a service created by the activity, use aidl. (I dont know how to get the current service if its registered from an activity)
4) Create a custom filter on the broadcastReceiver located on the same class as the activity, and use context.sendBroadcast(msg of custom filter) and in the custom filter call updateUI (same as one but more generic?)
The final flow is it would come from a BroadcastReceiver and ends up updating the UI without renewing the activity (unless the activity is dead?)
Kindly provide links/source code on your how you tackle this kind of problem.
View 1 Replies
View Related
Mar 3, 2010
Does anyone know how I might go about accessing an Activity in an application from a BroadcastReceiver (in the same application)?
(I have some state information in the Activity I'd like to update)
I'm not sure if there is a best practice for it.
View 2 Replies
View Related
Feb 17, 2010
Maybe it's easy, but I couldn't really figure this out right so far... I got a BroadcastReceiver waiting to get triggered by the AlarmMangager - this works fine.
Now: because the event, if it occurs, needs to refresh some elements on screen of the main Activity, I would like to send an Intent from that background BroadcastReceiver to my Activity - but only if it is currently in the foreground, aka active.
If it is not running or not visible, I don't care - and the last thing I want to do is start the Activity by my intent! I handle repainting of the views in my onResume method, so I don't care at all.
EDIT: my BroadcastReceiver is waiting for alarms that must be notified to the user. So, it must be there and declared in the manifest. The problem is: it will have to decide whether the mentioned Activity is currently up in front or not.
View 3 Replies
View Related
Sep 7, 2010
I'm developing alarm application. I'm using listview on activity to reserve alarm. after application finish BroadcastReceiver.onReceive() method, I want to remove check of list. But i dont know how to access to activity.
View 1 Replies
View Related
Apr 11, 2010
I've got an Android application which needs to be woken up sporadically throughout the day.To do this, I'm using the AlarmManager to set up a PendingIntent and have this trigger a BroadcastReceiver. This BroadcastReceiver then starts an Activity to bring the UI to the foreground.All of the above seems to work, in that the Activity launches itself correctly; but I'd like the BroadcastReceiver to notify the Activity that it was started by the alarm (as opposed to being started by the user). To do this I'm trying, from the onReceive() method of the BroadcastReceiver to set a variable in the extras bundle of the intent,Can anyone tell me what's different about passing a bundle from a BroadcastReceiver to an Activity, as opposed to passing the bundle from an Activity to a BroadcastReceiver?
View 2 Replies
View Related
Feb 3, 2009
I am trying to get a UI to present itself when an incoming SMS happens. When that happens, I would like to present a UI to the user.
I have a BroadcastReceiver class that listens to the SMS_RECEIVED event. I also have an Activity class that is capable of displaying the needed UI when the event happens.
The questions is: How do I start the activity from within the onReceive method of BroadcastReceiver?
I know others have done this but I can't seem to find any resources that illustrates how.
View 3 Replies
View Related
Sep 1, 2010
Not sure how to figure out which android project on android.git.kernel.org corresponds to the classes extended in some of the app examples in the SDK such as Activity, Intent, and ContentProvider.
View 1 Replies
View Related
Dec 17, 2009
We are developing a ContentProvider which is supposed to serve for specified packages. So we want to get the caller package name. Is there any way to achieve that?
View 2 Replies
View Related
Apr 6, 2010
I currently register a content observer on the following URI "content://sms/" to listen out for incoming and outgoing messages being sent.
This seems to work ok and I have also tried deleting from the sms database but I can only delete an entire thread from the following URI "content://sms/conversations/"
Here is the code I use for that
CODE:............
However I want to be able to get the recipricant and the message text from the SMS Content Provider, can anyone tell me how to do this?
And also how to delete one message instead of an entire thread?
View 2 Replies
View Related
Aug 14, 2010
I have a ContentProvider which is declared in the Manifest, when is it really created ? When the application is launched but before launching the first activity ? When the first query/update/insert is done ? When ?
View 1 Replies
View Related
Jun 29, 2009
I want to add an extra field to the phonebook on android. The field contains a new contact method and when clicked it should start my own application/intent. I have created my own content provider that stores the information. I want to add this contentProvider to the phonebook in the same way organizations and email are added to the phone book. So how do i do this? I tried adding a new contact method but the field KIND needs an integer input which seems to be predefined to some specific methods (EMAIL, IM, ADDRESS etc)
So do i need to add a new type of KIND or can I link my contentProvider to the phone book so that it shows up as an extra field in the phone book?
View 2 Replies
View Related
Aug 24, 2010
All the example codes, tutorials or video I see, there is always one ContentProvider per SQL Table with the SQLiteOpenHelper extension defined as a private static class... Is it some sort of standard design...to have one ContentProvider per SQL Table? Or I can define one generic ContentProvider and use its instance for ever update? Is there some issue with that? Could anyone please help as my application has like 5-6 tables.
View 12 Replies
View Related
Aug 18, 2009
Maybe it's an easy question, but I've tried to understand why all the content providers seem not to close the DB that they use. In the NotePadProvider example (in other providers is similar), it's used a Helper to manage the DB (that extends of SQLiteOpenHelper).
This helper has a method to close the DB (http://developer.android.com/ reference/android/database/sqlite/SQLiteOpenHelper.html#close%28%29), but in all the providers that I have seen (even in the example), this method is never used.
For example, in the query method of the NotPadProvider we use the helper to open a DB
CODE:...........
The mOpenHelper is create in the "onCreate()" method, but there is no reference to a mOpenHelper.close() in all the provider (maybe because there is no "close()" method in ContentProvider).
Do we need to close the SQLiteOpenHelper object? When we use it inside a ContentProvider, where is the right place to close it?
View 5 Replies
View Related
Aug 12, 2010
I have a custom class, which represents my data-structure. This custom class is in a normal Java-library, which is included in both projects. I have one Project with a ContentProvider which provides this data to Activities of other Projects. And an other Project with an Activity, where I want to handle this data in objects of this custom class.
How can I get this data to the Activity? The Cursor [1] only supports primitive Types.
[1] http://developer.android.com/reference/android/database/Cursor.html
View 5 Replies
View Related
Mar 5, 2010
I am writing my own sms receiver app and i want it to catch all the sms using a broadcast receiver. This on its own, is no problem, but i want to be able to stop the message being passed to the messaging app.
View 2 Replies
View Related
Jun 1, 2010
How can I test if there's a ContentProvider for a Uri ?
I'm currently doing a query on it and checking for a null cursor, but that generates an error in the system log each time, which I don't like to do.
View 3 Replies
View Related
Jun 20, 2010
I have an AutoCompleteTextView working with a ContentProvider that correctly pulls known information from a database when the user is typing and presents it. However, I would also like to support the automatic hints/word choice list you get when using apps like the Messaging app. I haven't figured out how to get that thin bar of word choices to appear. Can some one clue me in on how to use that in combination with my existing ContentProvider?
View 2 Replies
View Related
Aug 27, 2009
I would like to get the contact name, contact number, and contact email id using the contentProvider. Can any one please guide me to achieve this.
View 3 Replies
View Related
Aug 17, 2010
What is the lifetime of a ContentProvider in Android? After onCreate() is invoked, will the ContentProvider persist unconditionally for the lifetime of the process?
My ContentProvider manages a list of records, but only 1 is designated "active" and will be accessed by different applications a lot. I was wondering if it's safe to cache the index of this active record in memory as a member of my ContentProvider to speed up lookup.
View 1 Replies
View Related
Aug 16, 2010
If I call to a ContentProvider from a Activity, which thread is ContentProvider running in?
E.g. What happens if the Activity is killed and a query is executing in the ContentProvider? Say that you have a slow network query f.ex.
View 1 Replies
View Related
Jul 30, 2010
I am brand new to developing for android and have hit something of a stumbling block that I cant seem to get around.
Using the NotePad example, I have created my own ContentProvider to serve up data from a database that I will eventually host on a webserver. But that is lightyears away from where I am right now.
Just testing my ContentProvider has caused a bit of a headache that I cant solve. For some reason, when the provider calls SQLiteDatabase db = mOpenHelper.getWritableDatabase(); I get a null pointer exception.
Code Follows:
CODE:............
Stack Trace
CODE:......................
View 1 Replies
View Related
Dec 5, 2009
I have been stuck at a place , strange, I have a content provider class i.e class extends ContentProvider, I want to know about the method to show the dialog to the user when upgrading / creating a content provider or database from within content provider, I tried many ways for it, but nothing seems to be working, Can anybody here direct me to the reference or can tell me the way I can show progress dialog box from within contentprodiver.
View 11 Replies
View Related
Dec 15, 2009
In my application, I have created a ContentProvider. Is there a way for me to instantiate this ContentProvider when my apk is started? RIght now, the ContentProvider only instantiate when some one does a query.
View 2 Replies
View Related
Dec 2, 2009
I am writing my own ContentProvider for my own application. And there is a ListView with a CursorAdapter pulling data from my Content Provider. My question is when there is a data change in my ContentProvider, how can I notify my CursorAdatper to requery the data and then have the ListView updated?
View 2 Replies
View Related