Android :: Determining Current Foreground Application From Background Task Or Service
Jan 30, 2010
I wish to have one application that runs in the background, which knows when any of the built-in applications (messaging, contacts, etc) is running. So my questions are: How I should run my application in the background. How my background application can know what the application currently running in the foreground is.
View 4 Replies
Oct 6, 2010
Is there a native android way to get a reference to the currently running Activity from a service?
I have a service running on the background, and I would like to update my current Activity when an event occurs (in the service). Is there a easy way to do that (like the one I suggested above)?
View 2 Replies
View Related
Aug 21, 2010
I am currently writing my first Android application and I keep running into references to background and foreground services. Since I intend on using a service in my application I was hoping to get a clarification between the two and how they are used.
View 1 Replies
View Related
Jul 26, 2010
I am developing an application that has to capture the key events both in foreground and in background. I used the following code. But am unable to capture the keys in background.
CODE:............
I used broadcast reciever..
CODE:.................
View 1 Replies
View Related
Jul 23, 2010
The official documentation describes tasks as follows: All the activities in a task move together as a unit. The entire task (the entire activity stack) can be brought to the foreground or sent to the background. Suppose, for instance, that the current task has four activities in its stack three under the current activity. The user presses the HOME key, goes to the application launcher, and selects a new application (actually, a new task). The current task goes into the background and the root activity for the new task is displayed. Then, after a short period, the user goes back to the home screen and again selects the previous application (the previous task). That task, with all four activities in the stack, comes forward. Is there a way to programmatically detect when the task of the current Activity moves into and out of the background? I would like to know when the user has switched switched to another application, vs. when the user navigated to another Activity in the current app.
View 2 Replies
View Related
Apr 8, 2014
I have a Service that I am running in the background every minute. It's an IntentService and I start it like this:
Code:
Intent i = new Intent(context, GPSTracker.class);
PendingIntent pi = PendingIntent.getService(context, 0, i, 0);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
[code]...
That works, my Service is being run every minute (give or take a couple seconds for some reason) whether the app is up, closed, the phone is sleeping, whatever. how I should be getting the current location from this Service. I'm attempting to use LocationListener and a mix of getLastKnownLocation and hoping onLocationChanged will be called.
I think my problem is, onLocationChanged is barely getting called. Everytime the service runs and I do getLastKnownLocation I send a message to my database to check, I send a different message everytime onLocationChanged is called. I went to the store and back and getLastKnownLocation was called a few times, but onLocationChanged was only called once and it was incorrect. getLastKnownLocation always seems to be incorrect to.
Code:
protected void onHandleIntent(Intent intent) {
Log.i(TAG, "In onHandleIntent!");
Location currentLocation = getLocation(this);
if(currentLocation == null) {
saveLocation(-8.0, -8.0, "nothing", "nothing", "nothing");
[code]...
View 1 Replies
View Related
Apr 21, 2009
I am calling the ZXing scanner from Screen-A using intents. Once the scan is done control of course returns to the code behind Screen-A and I do some other work before calling Screen-B. Problem is the screen is black during this work period and I cannot determine the proper context to use to display a "working..." Toast/msgbox.
View 2 Replies
View Related
Jul 16, 2010
I have an application which requires a login at the beginning (this is the first activity). When the user logs in, I keep his credentials in the application (I extended android.application to add a field called 'key'). I would like to clear this field from memory (from application instance) an go back to the login activity.
I see the following possibilities: - Add a broadcast receiver to catch all possible event (call, click on menu, click on back, lock the phone ...) which clear the key field and launch the login activity - Use clearTaskOnLaunch for all activities except the login activity. But then until my application takes the focus again the key stays in the application object. (It seems it doesn't work with the go back button, maybe I need to use no history also) - Detect for each activity in all onPause or onStop events when application will leave the foreground to clear the key field and launch the login activity
The best would be to have a kind of OnPause method at application level but I think it doesn't exist.
View 9 Replies
View Related
May 13, 2010
The default behavior of an activity when BACK softkey is pressed is, GO BACK TO PREVIOUS ACTIVITY. If some the same activity is waiting for some response from server or some data updation is going on and then press BACK, I want to wait on the same screen till the current task is completely processed and then move out to the previous activity.
You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscribe@googlegroups.com For more options
View 12 Replies
View Related
Apr 3, 2009
I want run my application in background, with "Service component", If the application is running in background then there should be icon of application, so when user click on icon the application should come in fore ground. Is this possible in Android, anybody having suggestions plz welcome. There is provision of Notification Manager for icon, but it is not reacting to user events. Is there any other way to this.
View 4 Replies
View Related
Sep 11, 2009
I cant find anywhere how to change the Text COLOR in a webview. I can change the background color but not the Text.
Any Ideas? I want my webview to be white text on a black background instead of black text on a white background.
View 2 Replies
View Related
Jul 19, 2010
Is there any way to launch an activity w/ Intents (in this case the Browser) in the background, and then bring it to the foreground using a service or activity?
I know it's possible to bring apps to the foreground by launching an intent with FLAG_ACTIVITY_BROUGHT_TO_FRONT
But is it possible to initially launch the activity in the background?
View 3 Replies
View Related
Oct 19, 2009
In my application i wait on socket for network events.On some events i have to bring activity into foreground(make activity as running) if at all it is not in the foreground.
View 17 Replies
View Related
Aug 6, 2009
It would appear on a G1 (with the latest software update) that onUpdate () runs even when the widget is not visible. Is there a way of sensing that the widget is or is not visible or is otherwise in foreground? That is, running the code below shows a logcat message at whatever interval the Widget is scheduled to update, whether it's in foreground or not, whether even the screen is dim or otherwise in deep sleep. It would seem onUpdate should only be scheduled to run when the Widget is in the foreground or visible. Is this a defect in the G1, or is there some other API call to detect if the Widget is visible?
public class HomeScreenWidget extends AppWidgetProvider { ...
View 2 Replies
View Related
Feb 9, 2009
I have a subclass of android.app.Dialog and because I am using a light theme, the dialog title comes out as Black on a dark background which is hardly readable. This leads me to the question: how do I change the Dialog title background or foreground colors? Can I do this via a theme? Which property will it map to?
View 4 Replies
View Related
Aug 28, 2010
I would like to know what the best way would be to draw a background image (this would be pretty much static) and a foreground object which would move depending on user input in Android?
Sort of like a side-scroller game (when the foregroudn object needs to animate and change a lot more than the background).
View 1 Replies
View Related
Aug 20, 2010
Does anyone know how to, or if it's even possible to check the (foreground process/top of the activity stack) from a service?
View 20 Replies
View Related
Oct 6, 2010
I want to write a service for Android platform that is notified when the current foreground activity changes. Basically the service should do some tasks only when the top activity changes. Is there any way to subscribe and to be notified when this kind of event occurs? Or there is no possibility and the service should poll from time to time the list of running activities and to check what is the foreground activity ?Not preferable solution...
View 1 Replies
View Related
Aug 20, 2009
Is there any way for a backfround task to programmatically detect or recognize by learned id which application or screen (different package) is showing?
View 5 Replies
View Related
Sep 23, 2010
I have a very simple android project. I got the following error message when I try to run it. The emulator is running but the application doesn't come up. I couldn't find any useful information online.
CODE:..................
View 3 Replies
View Related
Aug 16, 2009
My applications carries on processing when the user presses the home key, and generates status bar notifications if something happens the user requested to be notified about.
If a user holds the home key and then selects the application, it is restored in its correct state with the activity on top that showed when the user left.
However, since the intent that is associated with the status bar notification is FLAG_ACTIVITY_NEW_TASK and I put in the class name of the activity that launched the application (I assume this is what I must do?), the launcher activity is started when the notification is "clicked". I can then switch the application back to the current activity by starting that "active" activity again, but then I seem to have two instances of the activity in memory, since I have to press back twice to leave it. And I suspect my activity stack is then messed up as well.
I have set the launcher activity to be singleTask, but that only helped a bit. From my reading I thought this would just give the task focus if the launcher activity is not on top, but instead it gives the launcher activity the focus.
Is there a way for a notification click to work more like the task switcher provided by long pressing the home button?
View 10 Replies
View Related
Sep 26, 2010
How do I close a whole hierarchy of activities and show a new activity not present in the current task?
Context
Consider a FTP browser that resumes the previous session on launch. Each folder is displayed in its own activity. When I click on a folder, a new activity is started for the folder. If I press the back button, the app returns to the previous activity, which corresponds to the the parent folder.
I can logoff from the menu at any time. Logging off should bring me to the login activity (not present the current task when the app has resumed the session), and close all the other activities. How can I do this?
From what I've read, if the activity were in the current task I could use FLAG_ACTIVITY_CLEAR_TOP in the intent, but this is not my case.
View 1 Replies
View Related
Aug 25, 2010
CODE:..........
Here is the code where the problem lies....
It doesn't give me an error it says exactly this when I run the android emulator
"[2010-08-25 09:12:42 - doppler_test] ActivityManager: Warning: Activity not started, its current task has been brought to the front"
What I think this means is that the intent of the bluetooth function and the button intent is only operation on a hierarchy system. What I mean by this is that if I were to move the button opperator above the Bluetooth stuff the button will work, but currently when the app is run Bluetooth works but when I press the search button nothing happens.
What else may be helpful is my XML code for the button so here it is......
CODE:..........................
View 1 Replies
View Related
Nov 2, 2010
I want to display a splash screen followed by my trial.class.I am not getting any error but warning as:
Warning: Activity not started, its current task has been brought to the front
I have different-2 approches for this each time this warning is being displayed.
CODE:.....................
View 8 Replies
View Related
Jan 14, 2010
There seems to be a couple of ways to go about having a background task being executed. My usecase is to have my app fetch a datafeed every x minutes, regardless of my gui is running, and regardless of whether the phone is sleeping or not. I use an alarmmanager to schedule an intent matching a broadcastreceiver. in the onRecieve method i start a service (startService), which spawns an AsyncTask. The task fetches data and stores it and then stopSelf() the service.
in the onRecieve method i aquire a PARTIAL_WAKE_LOCK, before starting the service, and just before calling stopSelf() in the service, i release it again. Is this really the best way to do it? Do i even need the service in this scenario? I experience odd behaviour with this setup, where the setup works for hours and then suddenly stops, which makes it very hard to debug. Does anyone have a simple foolproof method to achive the same end?
View 1 Replies
View Related
Nov 9, 2010
I have a task which I need to run in the background in my Android app. It reads data over the network and populates a database. It can take several minutes to run.
Once it's started, it needs to complete successfully without interruption. (Otherwise I'll end up with a broken half-populated database.) I realise I can never guarantee it will always complete, but I want to make it as hard as possible for the system to kill off this task. For safety I guess I will have it populate a temporary database, and then only swap out the old database for the new one on successful completion of the import.
It's a modal operation; it does not make sense for the user to be interacting with the app while the import is in progress.
My first attempt is using an ASyncTask with a Progress dialog to achieve the modality, but this obviously breaks the "don't interrupt" requirement. I could work around the screen-rotation issue with ASyncTasks, but I don't think that goes far enough.
At the moment I'm not sure if this should be an ASyncTask, a Service, an IntentService, some combination of these, or something else entirely.
View 2 Replies
View Related
Aug 31, 2009
I'm trying to run a background task which runs every minute or so for an android application but I am struggling to ensure that the task actually runs every minute. I've tried a variety of approaches from using SystemClock.sleep() to the AlarmManager (both repeating alarm and a fixed alarm) but it seems that unless the device is charging any kind of repeating system has a variable repeat rate once the device is unplugged. Is there any way to run a stable consistently repeating service?
View 2 Replies
View Related
Apr 9, 2009
Is it possible to get the currently running activity through Service..?
i.e. I have a service started by an Activity A, and now I want to stop the service by another activty say Activity B.
Since Activity B doesnt know about the service, i want to capture the events in OnKeyDown() of the Activity B in my service...
Is this possible.. How can i get the Activity B's object..?
View 6 Replies
View Related
May 5, 2010
When I kill tasks in ATC and then hold the home button, it still shows apps running. What's up with that?
View 10 Replies
View Related
Aug 4, 2010
Say that the user has started my App and then switched off to use the Browser (so we have 2 sets of Tasks running). After a while, something happens to my app that requires the user's attention, so it posts a notification to notify the user. Is there a way to bring my App's task (and the Activity on top of the stack) out from the background when user clicks on my notification?
View 2 Replies
View Related