Android : Check The Foreground Process From A Service

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?

Android : check the Foreground Process from a Service


Android :: Remote Service Process Persists - I.e. Won't Disappear From Process Table

Feb 21, 2009

At a certain point in my program, when I'm completely done with my service, my activity executes unbindService() and stopService() -- yet the process persists. I can tell that it persists because I run "ps" in "adb -e shell":

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

"adb logcat", I can show you the sequence of events:

ACTIVITY: context.unbindService(serviceConnection);

SERVICE: onUnbind();

ACTIVITY: stopService(serviceIntent); & returns true!

SERVICE: onDestroy();

First, my activity calls unbindService(serviceConnection). According to the documentation, unbindService() will "Disconnect from an application service. You will no longer receive calls as the service is restarted, and the service is now allowed to stop at any time." So that is fine, and it is happening.

Appropriately, we see the onUnbind() call happen on the service side. According to the documentation, onUnbind() is called when "all clients have disconnected from a particular interface published by the service." So this confirms the correct service connection is being passed, and that the service is responding accordingly.

Next, my activity calls stopService(serviceIntent), and returns true. According to the documentation, stopService() does the following: "If there is a service matching the given Intent that is already running, then it is stopped and true is returned; else false is returned." Again, this is happening and returning true.

In response, the service's onDestroy() method is called. According to the documentation, onDestroy() is "Called by the system to notify a Service that it is no longer used and is being removed. The service should clean up any resources it holds (threads, registered receivers, etc) at this point. Upon return, there will be no more calls in to this Service object and it is effectively dead."

At this point I expect the process to disappear from the process table. Yet it remains indefinitely. But why?

Also, the process is so persistent that I can bind to it again, and I see that it is the same exact process responding because the PID (process ID) is the same!

View 4 Replies View Related

Android : Difference Between A Background And Foreground Service?

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

Android : Get The Current Foreground Activity (from A Service)?

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

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

Android :: Want To Check Whether Process Is Still Alive Or Not Through Programmatically

Nov 26, 2009

I want to check whether the process is still alive or not through programmatically ,Can i do that i am trying to do it by process name in onCreate method but the issue is that the onCreate method is called always .When i check that in onCreate method i always get the process name and i can not kill the current app and switch to previous one.

View 3 Replies View Related

General :: Android Shell Command To Check If Process Is Cached

Sep 9, 2012

I am wondering what terminal command I can use to check if a process has been cached. On my Sprint Galaxy Nexus, rooted, with the latest build of the Paranoid Android jelly bean rom, I can go to my settings, click on apps, swipe to the "Running Apps" list, and click on the button at the top of the screen that says "Show Cached Processes," and that displays the list that I am trying to access. My reasoning for doing this, is to use "Secure Settings" in conjunction with "Tasker" to check if my "Groove IP" application is running. Initially, I was trying to use "pgrep -l com.*" and check that list for "com.gvoip" too see if "Groove IP" is running in the tray (pull down menu), but if the process is cached, it still shows up in that list. How to get a list of cached processes from terminal.

View 4 Replies View Related

Android :: Application Service Ever Run In Different Process?

Apr 26, 2010

If an application begins a Service via bindService or startService, will this Service object ever run from a process different from that of the application? I ask because many Android example projects begin a service and communicate to them using IPC which seems wholly unnecessary considering that, according to the Android Service documentation, "... services, like other application objects, run in the main thread of their hosting process." IPC, AIDL, and the IBinder interface only seem useful if connecting to a Service started by an application other than your own. Is this a correct or fair understanding?

View 1 Replies View Related

Android :: Process Down After Loadlibrary In Service

Apr 1, 2009

I need to load a .so library in my Service onCreate method, but the process just down after System.load. On the other hand, the same code can work in Activity. Are there some differences between activity and service in the way of load .so file.

My code class AisoundService extends Service

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

View 3 Replies View Related

Android :: Singleton In Different Service Which Share Same Process

Mar 25, 2009

I have two services, both of them lies in separate apk, which run in same process. The two service share same jar file by <uses-library> method. The jar file implement a class, say "test", is a singleton. But I found that two instance of test is created under this case, could anybody give me some tips? I want to ensure it's singleton. Code...

View 8 Replies View Related

Android :: Show Dialogs In Service Process?

Feb 5, 2009

I intended to show a dialog in a service process, then I tried to use the AlertDialog but got the below error message: WindowManager$BadTokenException: Unable to add window -- token null is not for an application The reason seems to be that the dialog is not used in a application context (activity should be fine?) Was there any way that can solve this problem?

View 2 Replies View Related

Android :: Design Considerations - Sync Process And Using Service

Sep 29, 2010

I'm designing an android app which will need to do the following steps:

1. User pushes a button or otherwise indicates to "sync data".
2. Sync process will use rest web services to move data to and from the server.
3. The data will be stored locally in a sqlite database.
4. The sync process should provide status updates/messages to the UI
5. The user should not be allowed to wander off to other parts of the application and do more work during the sync process.

The first time the sync process runs, it may take 10-20 minutes. After the initial sync, less data will be transferred and stored and I expect the process to take 1-2 minutes or less. I've been doing a lot of reading about android's AsychTask and various examples of using a Service. But I don't fully understand the design considerations and trade-offs of choosing one design over the other. I currently have my demo project stubbed out using an AsychTask. After watching (most of) Developing Android REST client applications:
http://code.google.com/events/io/2010/sessions/developing-RESTful-and...
I'm left confused the design patterns described here feel overly complex, perhaps because I just "don't get it" yet.

View 19 Replies View Related

Android :: Signal An AppWidgetProvider From Service Running In Another Process

Feb 2, 2010

I am attempting to signal my widget such that it receives my new Intent from my service

The code I am using to send from the service is as follows:

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

View 2 Replies View Related

Android :: No Network Connectivity In Service/AlarmManager Process

Mar 24, 2010

I have a Service/AlarmManager set to go off ever hour; as seen at: http://github.com/commonsguy/cw-advandroid/tree/master/SystemServices...

The Alarm triggers a Socket connection to communicate with a Web Server. I'm logging the interaction to a file so I can see it later. When I leave the phone on my desk for a day, it seems that more often than not I get a "Network unreachable" error when trying to do any networking.

I believe it is related to how deeply the phone goes into sleep. Is there a special kind of lock I have to hold, or some command required to prep the wireless radio so that it can be ready to access the Internet?

View 21 Replies View Related

Android :: Inter-process Communication With A Service And Notifications

Dec 13, 2009

I'm having an issue with inter-process communication with a Service and Notifications

The structure of my application is as follow: - ListActivity (TunnelDroid), once the user presses a listitem it will start a Service. The ListActivity is binded to the service for intra-process communication

- Service (TunnelManagerService): running in the background. This service will add a (permanent) Notification in the statusbar. Using a Handler I sometimes need to communicate with the ListActivity (to show GUI Dialogs)

- Notification: Once this notification is clicked it should open the ListActivity.

To add the action when the user touches the notification I use the following code: notificationIntent.setClassName("net.sourceforge.tunneldroid","net.sourcefo­rge.tunneldroid.TunnelDroid"); Then I use the intent to create the notification.

Unfortunately a new Intent is opened. When I press the back button the original ListActivity is shown. So I have two instances of my same class/list.

How could I make sure the original ListActivity is opened when the user touches the Notification?

It's OK for me if the original ListActivity was previously destroyed, but I cannot have two instances. The problem is that the Handler in the Service has a reference to the ListActivity (PARENT_ACTIVITY), so if another instance is created I have invalid references. I could overwrite the PARENT_ACTIVITY, but then when the user presses the back button I have an instance with no correct link to my Service resulting in a crash/nullpointer.

The complete source can be found here: http://tunneldroid.svn.sourceforge.net/viewvc/tunneldroid/tunneldroid. Attached you can find a drawing of (most of the) inter-process communication. Could someone point me in the right direction?

View 3 Replies View Related

Android :: How To Establish A Two-way Communication Between Activity And Service In Different Process

Mar 19, 2010

I'm working on establishing a two-way communication between an Activity and a Service which runs in a different process.

Querying the process from the Activity is no big deal. But I want the process to notify the Activity on events. The idea behind it is this: the service runs independently from the actual app. It queries a webserver periodically. If a new task is found on the webserver the process should notify the activity.

I found this thread over at AndDev.org but it doesn't seem to work for me. I've been messing around with BroadcastReceiver. I've implemented an interface which should notify the Activity but the problem is that the listener is always null since the Broadcast from the process is done via Intent, hence the class that extends BroadcastReceiver will be newly instantiated.

How can I establish a 2-way communication? This has to be possible.

View 3 Replies View Related

Android :: Check The Service With Some Name Running Once?

Nov 13, 2009

how to check that the service with some name is running once? also if i go out from my activity then my service is running & when i come to my activity the onCreate method is called so my service is created again in this case or running service will be attached again?

public class ServiceExampleActivity extends Activity { Intent intent; Button start,stop; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); intent = new Intent(this, ServiceExample.class); // service example is service class Log.i("-----service------", "Service Created"); }

View 2 Replies View Related

Android :: Check If Service Is Running

Mar 1, 2009

How do I check if a background service (on Android) is running? I want an android activity that toggles the state of the service -- lets me turn it on if it is off and off if it is on.

View 5 Replies View Related

Android :: Remote Process - Service Fetches Data From Network

Sep 15, 2009

I needed to call a remote service. The service basically fetches data from the network. I am bind the connection once,and then I unbind the connection when the user is no more in that page. Everything works fine.Except that when I call the sa,e remote method for 17th time,it just does not call the service at all.It neither throws the DeadObjecti Exception. I have run out of ideas.Is there anything that I may be missing.

View 7 Replies View Related

Android :: Automate Process Of Publish Droid App / Google Have Web Service To Do That?

Nov 10, 2010

We have several Android apps and found that the process of uploading apps for each release via Android Developers website slow and ineffective. We like to automate the process. To be more clear, we have automation for compiling and building the apps, it's a matter of uploading them to Android Market and fill in the app details for publishing. This is where we are left with manual publishing.

I am interested to learn how people automate the processing?

Does Google have a web service of some sort for publishing Android App on Android Market?

View 1 Replies View Related

Android :: Check If Intent Service Is Already Running?

Apr 6, 2010

Sorry for the newbie question, but does anyone know how I can check whether an IntentService is already running? I'm starting an IntentService from onCreate within a normal Activity, and that means that if the user minimises and maximises the application, it gets called twice. I'm wondering if I need to use something like the solution here http://bit.ly/du3VW5 or whether there's a simpler way.

View 3 Replies View Related

Android :: Check Activity Stack From Service?

Aug 19, 2010

I have an app that starts a service, then starts another activity previously selected by the user. Everything works on my app except I'm trying to get the service to kill itself, after it leaves the other activity without it having to come back to my activity. I've looked everywhere to see if anyone knows how to peek() search() the Activity Stack from a Service. Another way of wording is to check the foreground process from a service.

View 2 Replies View Related

Android :: Way To Check Phone Is In Standby From A Service

Feb 11, 2010

Anyone know how my service can check if the phone is currently in standby mode? And if I can trigger an event within my service when the phone comes out of standby mode...

View 3 Replies View Related

Android :: Check The State Of A Local Service

Sep 30, 2010

How do I check whether the local service inside my application is running?

View 1 Replies View Related

Android :: Service To Check Internet Connectivity?

Jun 29, 2010

I want to create an Android service, which notifies the main activity whenever disconnects and when internet reconnects again. I have following function for checking internet connectivity:.

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

But I want to know, how to use it in a service.

View 1 Replies View Related

Android :: Using Service - Check If Connection Get Broken

Nov 12, 2010

Iam connection to services trougth my app, I woul like to check if the connections gets broken, alert a message than.

Or is this taken carre of in android? If not, How should I take care of it? is there a timer?

View 1 Replies View Related

Android :: Keep Broadcast Receiver Process Alive / By Creating Service That Stays Around?

Sep 16, 2009

The app widget documentation indicates that the "widget provider"being a receiver of a broadcast service may not exist (the process) beyond the completion of the call.If I want to maintain state between two broadcast events, such as say widgetProvider.onUpdate(), can I start a local service and leave it hanging there until my widgets are disabled? If I didn't explicitly stop that service will it be loaded again and resumed when the device wakes up.

View 4 Replies View Related

Android :: Resulting Thread Id Scoped Per Process / Current Activity / Service?

Jul 21, 2010

When you do a Thread.currentThread().getId(), is the resulting thread id scoped per process or scoped to the current Activity/Service?

View 1 Replies View Related

Jelly Bean :: Unknown Android OS / Service Process Battery Drain?

Sep 16, 2013

What is weird to me is that on the closeup line graph the second half plummets much faster than the first half. But at the same time, the second half doesn't nearly have as many wakelocks (as indicated by the "Awake" bar being basically completely empty during that time.

What the mobile network colours represent but I never had this problem previously with it on all the time so this shouldn't be an issue. GPS is always on. Again, this was never an issue until supposedly now so this also shouldn't be an issue.

Now, the four big drainers are Cell Standby, Android System, Google Services, and Android OS. Cell Standby I know is due to a missplaced decimal point in the framework, so I know that's just false battery recording. Android System I don't have a clue what the problem is, I read somewhere it might have to deal with wakelocks. But it won't tell me what process exactly is causing battery drain. Google Services are well, google services. I don't know what are classified as google services exactly (like this was never a problem before..), and finally Android OS. Again, the battery statistics thing isn't nearly specific enough.

View 4 Replies View Related

Android :: How To Check If User Defined Service Is Already Running

Sep 6, 2010

I have a service that is running within the context of my application. It gets invoked at the start of the activity and then gets update when new data is inserted or deleted from the database. The problem is that everytime I start the activity , it restarts the service. As you may have guessed - not a very intuitive design. Therefore I was wondering if there is a way to determine if the service is already running before starting it. I know I can bind to the service but I do not want that since the main activity needs to exits after the database operation is completed. I know for system services, you can get the service details from the application context. How do you do it for user defined service?

View 3 Replies View Related







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