Android : Way To Access To Activity From BroadCastReceiver.onReceive?

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.

Android : Way to access to activity from BroadCastReceiver.onReceive?


Android : Start Activity From Within OnReceive Method Of BroadcastReceiver?

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

Android : How To Redirect BroadcastReceiver OnReceive?

Oct 13, 2010

What's the correct way (if any) to redirect a received Intent to another BroadcastReceiver? I have two BroadcastReceivers set to listen to the same intent. It works in development, but in production, only the first one registered in the manifest gets the intent. Can I call the other one's onReceive() method directly, passing the same context and intent? Is there a better way to pass the intent along once the first receiver is done with it?

View 1 Replies View Related

Android : Can I Initiate Threads In BroadcastReceiver's OnReceive Method?

Dec 18, 2009

My application has two components,one is Activity and BroadcastReceiver. I am using the BroadcastReceiver as inner class of my Application. The BroadcastReceiver's onReceive method is initiating a new Thread as Thread object,every time. In that i am trying to update the activity if it is in fore ground.If it is in back ground i am simply ignoring. But some times my application is hanging as my application's "HeapWorker" thread is taking 80-90% of the CPU.

View 2 Replies View Related

Android :: Access Database In BroadcastReceiver?

Dec 12, 2009

I have a problem when using database in broadcastReceiver.

I can't open the database created in the activity. e.g: malwareDB = new PackageDB(this);

The eclipse give me the error that "PackageDB(this)" is undefined.

It seems that the BroadcastReceiver doesn't support the database?

Do have have to access the data base in the "service"?

Here is the definition of "PackageDB":

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

View 2 Replies View Related

Android :: Access CallLog From A Service / Broadcastreceiver

Aug 17, 2009

Is there any way, to access the CallLog from a service or BroadcastReceiver?

View 2 Replies View Related

Android :: App Contains BroadcastReceiver And Activity

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

Android :: BroadcastReceiver Communicating With Activity

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

Android :: BroadcastReceiver To Listen For Activity Being Launched

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

Android :: Call Main Activity From BroadcastReceiver?

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

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 View Related

Android :: How To Unicast An Intent To An Activity With Inner BroadCastReceiver

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

Android :: Best Practice On Updating UI From BroadcastReceiver To A Certain Activity?

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

Android :: Update Activity From BroadcastReceiver / Practice For It?

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

Android : Inform Activity From A BroadcastReceiver ONLY If It Is In The Foreground

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

Android :: Pass Data From BroadcastReceiver Through To Activity Being Started?

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

Android :: Widget On Update / OnReceive

Aug 9, 2010

I initialize some arrays in an onUpdate() method and after that, using an intent and a button, I try to call onReceive() function which runs fine but cannot access arrays set in onUpdate() method. Why is that? Those array's are object variables and are declared public.Am I missing something?package net.aerosoftware.widgettest;
import java.util.HashMap;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.RemoteViews;
public class WidgetTest extends AppWidgetProvider { public static String ACTION_WIDGET_RECEIVER = "ActionReceiverWidget";
public HashMap<Integer, String> channelsImages;
@Overridepublic void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
{ Log.e("UPDATE", "Start");
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.main);
channelsImages = new HashMap<Integer, String>();
channelsImages.put(0, "one");
channelsImages.put(1, "two");
Intent active = new Intent(context, WidgetTest.class);
active.setAction(ACTION_WIDGET_RECEIVER);
PendingIntent actionPendingIntent = PendingIntent.getBroadcast(context, 0, active, 0);
remoteViews.setOnClickPendingIntent(R.id.buttonclick, actionPendingIntent);
super.onUpdate(context, appWidgetManager, appWidgetIds);
appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
Log.e("UPDATE", "End");
} @Override public void onReceive(Context context, Intent intent)
{ Log.e("RECEIVE", "Start 2");
if (intent.getAction().equals(ACTION_WIDGET_RECEIVER))
try Log.e("SIZE", "Size Of channel array: "+channelsImages.size());
} catch(Exception e)
Log.e("ON_RECIEVE_ERROR", " "+e.getMessage());
super.onReceive(context, intent);
Log.e("RECEIVE", "End");

View 2 Replies View Related

Android :: OnReceive Can Not Get Message When MMS Coming

Jul 31, 2009

I use the BroadcastReceiver to get the MMS information, but the onReceive can not get the message when MMS coming.

Code as following: Code...

This code can work when SMS coming. Does anybody give me some comments?

View 3 Replies View Related

Android : How To Get Context From A Broadcast Receiver OnReceive To Send To?

Nov 7, 2010

I basically want to make and intent and pass to a service from my BroadcastReceiver's onReceive(). So far I always used View.getContext(), but here, I'm stuck. How exactly can I get the context so I can use public Intent (Context packageContext, Class<?> cls). Or is there any other way I can create an Intent and send to a service?

View 1 Replies View Related

General :: Error Message From OnReceive?

Jun 18, 2013

My Samsung Galaxy S4 has started popping up the message "An error has occurred in onReceive" every few hours.

If an app is the culprit, how can it be identified? I am an end user, not a developer.

View 6 Replies View Related

Android :: Access Several Xml Views In Activity?

Aug 6, 2009

i have created some xml layout: 1- toplayout.xml 2- botlayout.cml 3- middlelayout.xml now i can only set one view as in setContentView(R.layout.toplayout); please advise how can i show all three views in my activity?

View 2 Replies View Related

Android :: Access Activity Below In Stack

Sep 8, 2010

I have pushed one Activity to make few changes. Now I want to pass all the changes to the previous(below) Activity. I dont want to create Activity again;and intead i want to access the previous activity.

View 1 Replies View Related

Android :: Access One Activity From Another In Same Package?

Feb 25, 2009

I have 5 activities in my project. How can i check the condition of 2nd activity from 4th activity? Based upon this condition i want to do something. If anybody know this please tell me. Am waiting for the response.

View 2 Replies View Related

Android :: Access Drawables Outside An Activity

Jun 1, 2010

How do access a drawable which resides in my project's res/drawable folder from outside an activity? The component which handles the loading of images is generic and is not inside any activity. I would like to display an image from res/drawable in case it can't be fetched from the web.

View 2 Replies View Related

Android :: Access To Element On Another Activity?

Aug 5, 2010

I have a TabActivity with two tabs-activities — FirstActivity and SecondActivity.

How can I access to any element (for example, change TextView's text) on FirstActivity from SecondActivity?

View 1 Replies View Related

Android :: Access Rows In List Activity

Jan 21, 2009

I want to include one button inside each row in a List Activity. When pressing one of these buttons it will be disabled and will perform a heavy task in the background (in a different thread to avoid screen blocking). After the action is completed the button will be enabled again and the row updated with some results obtained from that "heavy operation". Im filling my List with a custom SimpleCursorAdapter, its getView method calls super.getView and in the view (row) returned I access its button through findViewById and set my click listener (to disable it, and launch the heavy task in the background). Once this heavy task is finished I need a reference to this row view to find the button and re- enable it. SimpleCursorAdapter´s super.getView() reuses row views shown on screen to avoid creating many different rows instances, so when my "heavy task" is finished the row view reference i need to reenable its button may have been reused in a different row, so in the end I am modifying a button in a different row! I have tried different solutions, for example giving different ID to each row view (useless because it gets overwritten when the row view is reused) Obviously creating a different row instance for each row whether its shown on screen or not isnt the best solution.

View 3 Replies View Related

Android :: Access Large Layout In Activity?

May 13, 2010

I am having layout which I want to render on to different sizes of mobile (like WVGA854). Resource structure is like

reslayoutmain.xml
reslayout-largemain.xml

By default it is taking layout main.xml file itself of layout. Its not pointing to layout-largemain.xml. its throwing exception:Activity can not start resource not found. So can any one guide me how can I acheive this and how to support mutiple screens with different layouts like large,small and default along with images specified in respective dip folders.

View 1 Replies View Related

Android : Access Context Of A Class Which Is Not An Activity?

Jan 28, 2009

Can anyone tell me how to access context of a class which is not an activity?

View 10 Replies View Related

Android :: Access Handler In Service From Extern Activity

Jun 23, 2010

Ive set an in a running service a handler which does operation every X time. Now after certain time i wanna start an activity from that service, and in onCreate of the activity i wanna access that handler of the service(which started the acitivty) and stop it's schedualed operation

(mHandler.removeCallbacks(someTask));

any idea how will i access the handler which is in the service? the service and the called activity are in the same proccess.

View 1 Replies View Related

Android : Access A Method Of An Activity Inside TabActivity?

Oct 1, 2010

I would like to access the public method of an Activity run by a TabActivity using: Code...

Basically, what I what is to let the parent Activity call a method in child Activity in order to do something. Is this possible?

I did try this:((TeamHuddleScreenMsgsView)getTabHost().getCurrentTabView().getContext()).refreshModel(); but I'm encountering a ClassCastException. It seems that the getContext() still gives the TabActivity. Any help on how to get the child Activity?

View 2 Replies View Related







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