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
Aug 24, 2009
I have two activity in my project. I am callilng second activity from main activity. can some one tell me how can i pass some data to that activity? Simply i want to pass object array. Can some one tell me how can i do it ?
View 5 Replies
View Related
Jun 29, 2010
In my Android app,I start a new activity with startActivityForResult(). I get the result in onActivityResult() perfectly. My problem is that there is a small bit of data that I know before I start the activity and I need that value to be available in onActivityResult(), too. I tried attaching it to my intent as an extra, but it wasn't attached to the intent that is available when the activity returns the result. I made it work by storing the data in a global variable, but I really don't like that approach. Is there a better, right way to pass data through an activity (instead of just to it)?
View 1 Replies
View Related
Dec 21, 2012
This is my 1st activity code:
Intent i = new Intent(getApplicationContext(), CustomerLogin.class);
i.putExtra("GrandTotal", mGrandTotal);
startActivity(i);
This is my 2nd activity code:
Intent in = getIntent();
Bundle b = getIntent().getExtras();
String total = b.getString("GrandTotal");
TextView grandtotal = (TextView) findViewById(R.id.grand_total);
grandtotal.setText("Welcome ," + total );
Here the value is pass from 1st to 2nd activity successfully. Now i have to pass these value to third activity.how can i do.
Now this is my 2nd activity:
if(isUserValidated && isPasswordValidated)
{
Intent intent = new Intent(CustomerLogin.this,PayPalIntegrationActivit y.class);
intent.putExtra("GrandTotal", total);
intent.putExtra("login",username.getText().toStrin g());
startActivity(intent);
}
This is my third activity:
Bundle b = getIntent().getExtras();
String total = b.getString("GrandTotal");
TextView grandtotal = (TextView) findViewById(R.id.check);
grandtotal.setText("Welcome ," + total );
Now i have to run the app means am getting the total value on 2nd activity.but am not getting the total value in 3rd activity.
This is my full source code:
1st activity:#5564017 - Pastie
2nd activity:#5564018 - Pastie
3rd activity:#5564020 - Pastie
View 2 Replies
View Related
Oct 30, 2010
I'm trying to pass data from notification to activity.
View 1 Replies
View Related
Jun 12, 2010
I am want to pass data back from a Thread to Activity (which created the thread). So I am doing like described on Android documentation.Only one thing I am missing here - where and how should be defined mResults so I could access it from both Activity and Thread, and also would be able to modify as needed? If I define it as final in MyActivity, I can't change it anymore in Thread - as it is shown in example.
View 1 Replies
View Related
Nov 2, 2010
I wounder if there is some possible to know from which parent Iam coming from in the child so I can do different stuff depending on who the parent is of the activity.This is how Iam going over to the child. But I don't know how to handle this in the child to check who is the parent. The above code is used on one of the parents,, is there somehow I can use "EQ_CODE_SELECT_LOCATION"? Also I wounder how is possible to send data to a child activity?
View 1 Replies
View Related
Jul 20, 2010
How do I get data within an Android Service that was passed from an invoking Activity?
View 1 Replies
View Related
Dec 20, 2009
I wanna know how to pass data from current Activity to paused Activity?
View 3 Replies
View Related
Nov 24, 2010
I am pretty new to this but I was told I could get good help here. A friend and myself are playing around with creating Android apps (using ADT)
Here is how we are trying to make the program: in activity, user sets threshold values for the X and Y axis on accelerometer. When user hits button "Start", startService is invoked and starts TiltService.
TiltService is designed to run in the background always on the phone without user interaction. TiltService constantly compares the threshold with the accelerometer values and will vibrate if they are off.
My problem is I can't seem to get the putExtra() data correctly. I have overridden the onStartCommand in my service but I get the message "unreachable code" when I save the getExtras() to a bundle.
Here is the relevant code (I can post the whole thing, just do not want to clog up page) code...
I thought I understood the basic of how Intents could pass data, but I guess I don't. Is it obvious what I am missing?
View 2 Replies
View Related
Nov 2, 2010
I have a TabActivity, and each Tab corresponds to its own Activity. In one of them, in the onCreate method, I use startActivityForResult to show a dialog (specifically, Bump's BumpAPI activity).
code:...............
The problem is that when the screen orientation changes, it tries to create the tab's activity again which makes another BumpAPI dialog, resulting in multiple stacked on top of each other. Do I have a hook into the started activity to cancel the previous one when the orientation changes?
A workaround seems to be to add a button that when clicked, starts the second activity, but that adds an unnecessary step.
Also, I can't fix the screen orientation for the entire tabActivity because some of them require typing and users may want to use their physical keyboards.
View 1 Replies
View Related
May 1, 2010
I have following problem with my application: From my main activity ("activity 1"), there is a menu from which user can launch an action. This action will result in an Intent being received by a BroadcastReceiver, defined in my application. Finally, this BroadcastReceiver will start an activity ("activity 2") to deal with this intent.
The problem is that I have a "quit application" entry in my menu, and I can only finish() currently active activity. ie I am not able to finish "activity 1" from the menu of "activity 2". And I can't use startActivityForResult() as "activity 2" can't be started from "activity 1". Any suggestion would be much appreciated Thank you very much guys, regards.
View 4 Replies
View Related
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
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
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
Jun 2, 2010
first.java String[] items={"one","two"}; Bundle map = new Bundle(); map.putStringArray ("link",items); Intent myintent = new Intent(view.getContext(),two.class); myintent. put Extras (map) ;startActivityForResult(myintent,0); second.java Bundle map=this. get Intent() .getExtras(); String links=map.getString("link"); tell me that how can i get the two string values from one activity to another one. such as links[0]="one"; and links[1] ="two";
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
Feb 15, 2009
Is there already functionality similar to the push registry or wireless messaging API in J2ME implemented in Android? Or at least plans to do so?I have been looking at this issue for a while, because in a corporate environment it is essential to be able to push information out, or trigger actions via SMS or other connections.I have successfully sent an SMS between emulator instances, and successfully received an SMS by using a BroadcastReceiver on another emulator instance. I have also been able to use SmsManager. sendDataMessage to send a data message to a port on another emulator instance, but in this case the BroadcastReceiver is never triggered. This seems to be the closest the API's get to what I'm looking for.
View 3 Replies
View Related
Mar 29, 2009
I have created a broadcast receiver statically by specifying it within the Manifest, and I have also created the "same" broadcast receiver in code and have registered it with the application context. The static way works very well, but the dynamic way does not receive the expected broadcast. It could be that I am not creating the intent filter correctly, or that I need to register it with some other context somewhere. Please see the code examples to see what I am doing. This is related to receiving data SMS, it works very well on a device using a broadcast receiver defined in the Manifest. The correct permissions are set for both examples.
The following is from the Manifest, and the resulting receiver gets the expected broadcasts:
CODE:.....
The following is the code example that doesn't work (it does work with an intent like "android.provider.Telephony.SMS_RECEIVED" but not for data sms):
CODE:.....
The question is - why does this broadcast receiver get notified of the incoming data messages? It seems some other resource is notified when the Manifest version of the receiver is created...
View 4 Replies
View Related
Mar 31, 2010
I just want to get numbers of times to be used for each Activity.
So the very straightforward method I thought is increasing the count for an Activity when it was started. But how can I get the information?
View 3 Replies
View Related
Jun 18, 2009
Is there a way to do this?
Can you access the activity stack in a way to grab what activity came before the one now in view?
I have a situation where an activity needs to know where it was started from, so it knows what data to display in that current activity.
View 7 Replies
View Related
Oct 19, 2010
How can I know what Activity has started the current Activity? Is there any specific method like, i.e. getIntent().getCallerActivity() or the only way is saving some information within the Intent using putExtra()?
View 1 Replies
View Related
Aug 25, 2010
I have a central activity that can be launched from two separate classes. I was hoping that in this central activity I could have an IF statement like
if(this.getIntent() == MainMenu.class)
{
// Do something here
}
But obviously that isn't legal so how could I structure an expression to check from what class an intent was started.
View 2 Replies
View Related