Android :: OnStart() Not Called When Service Restarted After Being Killed?
Jul 25, 2009
I have a service that needs to hold a persistent TCP connection, think IM. I'm reluctant to use setForeground() - the service being down temporarily isn't that big a deal, and I am assume I can trust that I'll be run again once memory is available, correct? The problem here is this. The service was started via startService() before being killed. However, when it is restarted, only onCreate() is executed. This makes it hard to continue, because starting work onCreate() means I can't even bind to the service (to say query it's status) without it doing so. Is this a bug or per design? What is the status of the service after it is being restarted? Is it consider "started" by the system, i.e. waiting for a call to stopService()?
View 2 Replies
Mar 31, 2009
I have noticed that if my background service crashes the system will automatically restart the service after 5 seconds. This is great, but I have noticed that only the onCreate method gets called and not the onStart method. Does this mean the service is properly restarted or do I need to do something special in the onCreate method to make sure it is? I did have my initialisation logic in the onCreate method and my starting service logic in the onStart method but it looks like it will all have to be in the onCreate method.
View 2 Replies
View Related
Dec 14, 2009
I got my hands on Android which is really fun. But at some point I don't seem to understand the concept. I've got a Main class which reads like this:
CODE:....
In the onCreate(...) I set the layout to setContentView(R.layout.main); and add an OnTouchEvent Listener to the sole View in main.xml: myView.setOnTouchListener(new OnTouchListener() {@Override public boolean onTouch(View v, MotionEvent event){...
As you can see I also implemented a SensorEventListener which is used if required. All works fine so far.
But my problem is this (at this point my misunderstanding kicks in): whenever I rotate the device the onCreate(), onStart() etc. methods are called, causing my app to act as if it just started. Furthermore, I feel unable to implement an onSizeChanged(int w, int h, int oldw, int oldh) { ... } Listener.
Can anyone please explain where my error in reasoning is? I am working on a tiny app which is more or less done, except for the just mentioned bug(s). Maybe I got it all wrong but it does what it is supposed to do (i.e. sending touch positions and accelerometer data over the network via UDP).
View 14 Replies
View Related
Mar 7, 2010
In the 1.6 API, is there a way to ensure that the onStart() method of a Service is called after the service is killed due to memory pressure?
View 4 Replies
View Related
Mar 7, 2010
In the 1.6 API, is there a way to ensure that the onStart() method of a Service is called after the service is killed due to memory pressure? From the logs, it seems that the "process" that the service belongs to is restarted, but the service itself is not. I have placed a Log.d() call in the onStart() method, and this is not reached.
View 1 Replies
View Related
Sep 28, 2009
My activity bind a service. I want to call the service's function in activity's onStart/onCreate function, but it doesn't work. The service started sunless but the connection is null. When I just call the service's function in other function (onClick for example),
View 4 Replies
View Related
Aug 31, 2010
I have an Android application with a background running Service. When the Service crashes or gets killed by Android I can see that Android tries to restart it again. However the Service never actually restarts, I can see Android scheduling the restart but it new actually happens.
My code is as follows:.................
View 1 Replies
View Related
Sep 10, 2010
From what I can tell -- if you return START_NOT_STICKY from Service.onStartCommand(...), the system should not restart a service if it crashes. However, I'm not seeing that behavior -- any ideas on what could be restarting the service?
View 4 Replies
View Related
Jun 25, 2010
This is where it gets weird. When I tried to call out from my DINC, it would start dialing, then simply stop and say "call ended". During this apparent outage, CityID (worst crapware ever!) reactivated itself after a month and a half of being done with my trial (got the DINC on 4/29). Even though my calls weren't going through, CityID was identifying the location of the numbers I was trying to call.
After a couple hours, service resumed, everything was fine and CityID stopped working again (thankfully). When I go to my call history, all the numbers that I tried to call during that time have the city and state information from CityID. All the numbers before and after do not? Weird! I thought after the two week trial it was supposed to go dormant? I hope it never reactivates again as it has never, not once, been correct regarding the location of the number calling.
View 2 Replies
View Related
Nov 1, 2010
Suppose you have a download service that downloads files asynchronously. For each download intent received it will put the URL of the file to download and the start ID into a job queue and return START_REDELIVER_INTENT. A worker thread then processes that list and calls stopSelf with the start ID it just processed. My question is: If the service's process gets killed and the service restarted, will the service receive all the intents (with the URLs) it hasn't called stopSelf on before it was killed or does the service receive the last intent only? It seems the API docs are ambiguous on this.
The docs say
"if this service's process is killed while it is started [...], then it will be scheduled for a restart and the last delivered Intent re- delivered to it again [...]", indicating that only the last intent gets redelivered (which would be terrible in this use case), but they also say "The service will [...] be re-started if it is not finished processing all Intents sent to it (and any such pending events will be delivered at the point of restart)."
View 4 Replies
View Related
Jun 29, 2010
I have a service in my app the creates an alarm and runs a check ever X minutes. I am new to android and I was wondering is there a way to prevent another app such as ATK (advanced task killer) from kill my service/alarms? It seems that if I normally close the app my alarms still work but when I go to ATK and stop the app the service dies as well. Maybe thats the point, but this service is rather important and most users would want it to run even if the app itself is no longer running. I assume that if the system kills it for whatever reason then their is nothing you can do about it. Could someone please inform me on this issue and a possible solution to do what I need?
View 3 Replies
View Related
Jun 10, 2010
I have a service running in the background. It starts on device boot. Also, I have one activity (that appears in the task launcher) in which I have provided buttons to start and stop the service.
Now, I install the application on the phone and I start the service using this activity (and not on-device boot). As expected the service starts and starts doing its designated task. I no-longer need the activity. So it goes out of sight and may not be required for a long time now.
My question is, now, if the android platform kills this activity, will it kill my service too ? (This is because I see that after few hours, my service is not running anymore.). If this is true, then will the service continue running longer if the service was started on device boot.
View 11 Replies
View Related
May 7, 2010
It is very important that my service stay running until someone with a password stops the service from my UI screen. My app runs great but it is designed to be turned on/off by parents (with a password) on their kids phones. I have managed to make everything work but the problem I'm having is that if the kid uses a task manager to kill my service then my app is useless. I would be grateful to anyone who knows a way to either
1) monitor the service and start it back up automatically if its "killed"
or
2) prevent someone from being able to kill it except from the activity (administration screen) that launched the service. Or both?
View 2 Replies
View Related
Aug 25, 2009
I have a service that polls for data. To indicate this to the user I have a persistent notification in the statusbar. In some cases when the device goes low on memory it destroys the service but OnDestroy is not called. Later when there is available memory OnCreate is called. Is this normal behavior? I had hoped that OnDestroy would be called to I could remove the notification in the statusbar. Now the user thinks that the service is still running, while it has been stopped by the OS.
In order to restart the polling how do I know that the OnCreate is really a restart event and not first time creation of the service? I thought about checking for the presence of the notification in the statusbar, but I couldn't find a API to check if a notification was showing or not. I have not tried "SetForeground" on the service, since the service isn't that important to the user, but maybe that would minimize the problem.
View 4 Replies
View Related
Sep 5, 2010
I have an app widget that uses a Service to handle updates (as per the SDK sample). If a task killer kills the service, the widget obviously stops updating. Is there any way I can notify the widget that the service has been killed so it can attempt to restart it?
View 3 Replies
View Related
Aug 29, 2010
I just want to know how detect that the activity or service has been killed by the advanced task killer? I was expecting the onDestroy method to be called, but it doesnt!
My app starts the background service on boot. The activity is not started except from menu. But its name appears in the advanced task killer list. When I try to kill it, it doesnt call the onDestroy method neither the service's.
View 1 Replies
View Related
Oct 4, 2010
Is there a way to notify an activity/service of a force-close request right before it gets killed?
I mean when the user hits the force close button in Menu>Settings>Applications>Manage applications>app name>Force Close.
View 2 Replies
View Related
Nov 10, 2010
I have an Android service that's responsible for firing notifications at certain points in time. I use an android.OS.CountdownTimer for this. An activity creates and starts the service. If the phone is locked, notifications that are within let's say 1min are shown. Notifications that are much later are never shown. The service is unbound from the activity when the activity is onpause.
As long as the phone doesn't lock the notifications are generated, even if the activity is stopped and unbound from the service.
It seems to me that the service is stopped/killed. When I make the application debuggable and debug it on target, it works fine, also when the activity is stopped and the service is unbound.
The app is developed for v1.5 and runs at Galaxy S with 2.2.
Service is started as shown below
CODE:.................
View 1 Replies
View Related
Aug 10, 2010
Recently, I installed FRG01B. I had no problems with it except for the fact that I couldn't get the phone to mute.
I noticed that there was a really cool version of FRG22 out by Liquid Frozen Yogurt 1.3 (FRG22).
I downloaded RSD Lite, SPRecovery_ESE81.sbf, and I downloaded the 64 bit drivers for the Droid. I am using Windows 7 Ultimate Edition 64bit. I got the files from this page: FRG01B.SBF for Droid courtesy of RootzWiki - Droid Releases - AllDroid Public Board - FRG01B.SBF for Droid courtesy of RootzWiki - Droid Releases - AllDroid Public Board - AllDroid.org > Home
Anyway, I installed RSD Lite and the drivers. I opened RSD Lite and opened the SPRecovery_ESE81.sbf file. I clicked show device, but nothing was showing up in the window, but below it said connected. I clicked START. After my phone rebooted, it's shot. No service, no battery life, and it keeps rebooting itself. What can I do! Someone please help! My Gmail address is chim777@gmail.com and I will be available for chat as well. I will keep checking this thread every few minutes. Someone please help as I have no clue what the hell I did. All I wanted to do was root my phone.
View 10 Replies
View Related
Sep 14, 2009
As a point of example for my problem, I wrote a single Activity which binds to a service and then accesses a property to display. The problem is that my TestServiceConnection.onServiceConnected method is never called, and I don't know why.
Here is the code:
CODE:......................
View 3 Replies
View Related
Apr 4, 2010
I am getting IllegalArgumentException: Service is not registered when i try to stop my service by initially calling unbindservice and then stopService.
Before calling unbindService i first check if my service is still bound by checking (mBoundService - obtained from the ServiceConnection) I also check if the service is not stopped and only then i call the unbindService But I still get the error. From the posts that I read only I found out that both these calls are asynchronous and that the service will only stop when nothing is bound to it.
View 2 Replies
View Related
Jul 26, 2010
In the implementation of my remote service's published API, is there a way to identify which client called a given method? For example, is there a way to obtain a unique ID or address of the caller? I already cache an AIDL callback reference to the client, but not sure how I can use this for identification.
View 4 Replies
View Related
Aug 2, 2010
Whenever the memory needs to be reclaimed, the process is being killed by Activity Manager Service in killPidsForProcess. I have a back button in my activity window on right corner of the title bar.
I want to kill the activity completely on clicking the close button. Can I reuse the same function and will it have any major effect? Please help me out in this.
View 3 Replies
View Related
Sep 10, 2010
I am trying to write an app that cannot be killed by a user or another application. I understand this goes against what Android has designed for its platform, this is more of a proof of concept. The plan is two have two apps, app1 and app2. When app1 starts it will start app2 and then bind onto app2, when app2 starts it will make sure app1 is started if not, then start it and bind onto app1. The point of app1 binding on app2 and app2 binding on app1 is so when one of them gets killed a method will be called that the binding has been disconnected and the app can then be restarted. I currently have the apps starting each other when they start up but I cannot seem to get them to restart when I force close one of them.
For App1 service I have and app2 very similar:
CODE:..............
And for my class that implements ServiceConnection I have:
CODE:............
I think the issue I am having is that onServiceDisconnected never gets called when app1 or app2 is killed. I think this may be because I am not correctly binding to a service.
W/JavaBinder( 884): ibinderForJavaObject: 0x436274a0 is not a Binder object
W/JavaBinder( 891): ibinderForJavaObject: 0x43621d30 is not a Binder object
How can I bind services together so when one gets force closed that I will get a notice on the other?
View 2 Replies
View Related
Apr 14, 2010
I'm trying to start a floating activity from onStart to retrieve some info from the user right when the initial activity begins.
I have the following:
CODE:............
And callProfileDialog() is just:
CODE:..........
ProfileDialog.class returns a String from an input box. If the result returned is RESULT_CANCELED then I restart the activity.
The problem I'm having is that when the program starts, the screen is just black. If I hit the Back button a RESULT_CANCELED is returned then the initial activity shows as well as the floating activity (since it recalled itself when it got a RESULT_CANCELED). Why can't I get the activities show by calling ProfileDialog.class from onStart()? I got the same result when I called it at the end of onCreate() which is way I switch over to use onStart().
I have also tried the following:
CODE:.........
But this doesn't work either. It all works fine once I hit the back button but without doing that, it's all black.
View 3 Replies
View Related
Oct 5, 2010
In the Android Application Fundamentals it says that after the call to the onStart()-method of the activity lifecycle either the callback method Resume() or onStop() is called. In case of an "normal" Start of an activity the system calls onCreate(), onStart(), onResume().But does somebody know an example where onStart() - onStop() are executed one after another?
View 2 Replies
View Related
Oct 7, 2009
I want to display a ListView with checkboxes, and I want some of the checkboxes pre-selected. The ListView has setAdapter called during onCreate, and the list information appears when the screen is drawn. However, when I attempt to set certain list items as checked, my ListView reports getChildCount() = 0.
My SharedPreferences contains a list of sounds that have been previously selected, as a comma delimited string of list indices. Because the list appears to have no children in onStart, my attempts to set items as checked fails.
On the good side, once the list is rendered, I can select entries and hit Back, and my selection is stored to SharedPreferences correctly.
How can I load my previous selection into the list? Should I be using something else here?
In the spirit of open source. here's my code:
CODE:.................................
View 12 Replies
View Related
Oct 26, 2010
I am running into an issue with the way my asynctasks are executed. Here's the problem code:
firstTask = new background().new FirstTask(context);
if(firstTask.execute().get().toString().equals("1"))
secondTask = new background().new SecondTask(context);
What I'm doing here is creating a new asynctask object, assigning it to firstTask and then executing it. I then want to fire off a separate asynctask when the first one is done and making sure it returns a success value (1 in this case). This works perfectly on Android 2.0 and up. However, I am testing with Android 1.5 and problems start popping up. The code above will run the first asynctask but doInBackground() is never called despite onPreExecute() being called. If I am to execute the first task without the get() method, doInBackground() is called and everything works as expected. Except now I do not have a way to determine if the first task completed successfully so that I can tell the second task to execute. Is it safe to assume that this is a bug with asynctask on Android 1.5? Especially since the API says that the get method has been implemented since API 3. Is there any way to fix this? Or another way to determine that the first task has finished?
View 2 Replies
View Related
Aug 16, 2010
I know on screen orientation changes activity restarted, but suppose i don't want to restart the activity then what should I do? I had tried it by adding in manifest.xml. android:configChanges="keyboardHidden|orientation"
and override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); }
But still activity restarted each time when I change screen orientation.
View 17 Replies
View Related
Nov 17, 2010
I have an activity (say activity A) which displays video using a mediaplayer, rendered in a surfaceview.
The use case is to pause the video, start another activity (say activity B), then come back to activity A.
Activity A is stopped but not destroyed when going to B, which is good.
The surface view (since not visibile) IS destroyed (as observed from the notification callbacks). When coming back to activity A, and restarting the mediaplayer using start(), the media player does play back the audio, but video is not seen. Errors like this one are output on Logcat:
CODE;......
Unfortunately, using the new instance of SurfaceHolder as provided by surfaceCreated() doesn't help (i.e. provides the same error).
I have read in various posts a solution would be to reset the mediaplayer and restart it completely, however it is not efficient, as the end user would have to wait for the whole player preparation cycle + seekTo last position within the stream.
As shown with the fact the audio plays back, it should be a matter of plumbing between the the video decoder and the new surfaceholder/view.
What should be the best solution (best = fastest) to resume video playback when resuming the activity?
View 3 Replies
View Related