Android :: Service Restarted With All Unfinished Intents That Returned Start Status START_REDELIVER_INTENT?
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
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 3, 2010
I have a .Net Web Service which returns a single integer value. When i call upon it from my application, no value is returned. Nothing at all really happens. I set up breakpoints and watched it's progress and it seems the problem is coming from when i get to this line:androidHttpTransport.call(SOAP_ACTION, envelope);
I have a hunch that my URL string is the problem. I've tried replacing the "localhost" in my URL string with my local and network ip with no luck. Whenever i replace the localhost with the ip in my browser i get Server Cannot Access or Unable to Connect pages. Does anyone know a solution to this problem?
View 2 Replies
View Related
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
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
Sep 22, 2010
I am trying to start an activity from the notification bar but it needs to get an int. From activity to activity I would just put an int into the intent but I can't seem to figure out where to add the extra for the notification bar? Is this possible? If not is there a better way to do it?public void notifyMe()Code...
View 1 Replies
View Related
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 15, 2009
I need to be able to handle/catch Intents while my Activity is closed. So I am looking at either a Service or a BroadcastReceiver. Is it possible to "receive" intents to a service itself? I tried to search, but could not find anything helpful. With a BroadcastReceiver, I am not exactly sure how that works outside of an Activity. Does it depend on the Activity being open/running? Can it run by itself?
Let's say that my Activity is killed by Android(or a task killer app), does the BroadcastReceiver still receive intents and process them? I have used a BroadcastReceiver as a widget, but I do not want to use a widget this time. My goal is to have the user open the Activity to set some options. From there, they would be able to close the Activity, but I would still be able to process Intents that were sent out by the system. I am still fairly new to Android development, so I could be so far away from where I need to be.
View 1 Replies
View Related
Sep 13, 2010
What is the difference between 2 ways of interaction between applications on android:
1. implementing service in app #1 and using it in app #2.
2. handling intentions and posting answer intention.
View 2 Replies
View Related
Jul 6, 2009
I'm writing an application that consists of a background Service and one or several Activities acting as UI towards this. There will most likely be several different UIs for this service that will installed later on, like custom widgets or UIs. The question is how to solve this in the most efficient way. Is it better to only use Intents for communication between UI and Service (sending control commands with Intents from the UI and listening for Intents from the Service for state and data updates) or should I prefer using IPC communication (AIDL -> Java Stub, binding to the service etc.)?
Since the UI might be started long after the service is started, I would either need to use sticky intents to signal current state, or have a very frequent intent sent by the service if choose to go with the Intent-based design. Which one would be the preferred way in that case? I've read that sticky intents are much more resource consuming than normal intents, but are intents more consuming than IPC directly towards the service? Also, is really an AIDL the right way to allow third-party integration? Intents sounds better, since they are also asynchronous.
View 12 Replies
View Related
Apr 12, 2010
I currently have a Service in Android that is a sample VOIP client so it listens out for SIP messages and if it recieves one it starts up an Activity screen with UI components. Then the following SIP messages determine what the Activity is to display on the screen.
For example if its an incoming call it will display Answer or Reject or an outgoing call it will show a dialling screen. At the minute I use Intents to let the Activity know what state it should display. An example is as follows:
Intent i = new Intent();
i.setAction(SIPEngine.SIP_TRYING_INTENT);
i.putExtra("com.net.INCOMING", true);
sendBroadcast(i);
Intent x = new Intent();
x.setAction(CallManager.SIP_INCOMING_CALL_INTENT);
sendBroadcast(x);
Log.d("INTENT SENT", "INTENT SENT INCOMING CALL AFTER PROCESSINVITE");
So the activity will have a broadcast reciever registered for these intents and will switch its state according to the last intent it received...............
View 2 Replies
View Related
Nov 1, 2009
I'm rather new to Android, so please bear with me. I'm developing an application running a service in the background. The service is ONLY supposed to run when requested somewhere in the UI. The service must be able to be stopped through the UI as well. At the same time, while running, the service must be able to pick up intents such as "intent.action.DATA_SMS_RECEIVED" and "intent.action.NEW_OUTGOING_CALL".
View 2 Replies
View Related
Sep 29, 2010
Is it possible, with an IntentService, to send another intent to the IntentService from within the IntentService? For example, say my IntentService is processing an Intent which has it write a bunch of data to the database. During this time, several other Intents to write other data may [or may not] have been queued up in the IntentService. Suppose, after processing that Intent by writing the data to the application's database, I want to queue up another Intent to send that data via web service to "the cloud." Perhaps I want to queue this processing in another Intent because sending to the cloud is secondary. Is it possible? Would it cause any problems if the Intent being processed is the only Intent in the queue at the time the IntentService is trying to queue another Intent?
View 2 Replies
View Related
Feb 16, 2010
I am little confused with the use of intents used for sending data to activity from service. In my application I have to have startactivity from the service and have to pass data ,so that activity can utilize the data while launching.For this i have written the following code Intent intent = new Intent(Service.this,Activity.class); intent.putExtra("data", data); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.start Activity(); I assume that the data is passed to the activity and can be parsed on the oncreate function of the activity.Now the service running in the background has to pass data to the activity continously for UI updates.For this I have written the following codeIntent intent = new Intent(Service.this, Activity.class); intent.putExtra("Data", data); intent.setAction(Intent.ACTION_ATTACH_DATA); sendBroadcast(intent,null); (Do I need to broadcast the intent???) In activity I have done following things:- Implemented broadcast reciever:private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_ATTACH_DATA.equals(intent.getAction())) { Bundle extra = intent.getExtras(); float Data[] = extra.getFloatArray("Data"); update(Data);
View 4 Replies
View Related
Aug 18, 2010
I have a Receiver for BOOT_COMPLETED intent and it will start a Service by calling startService with an intent and the Service processes that intent in onStartCommand function by spawning a thread that does a HTTP post to a server.On powerup, sometimes it takes 3 to 5 seconds to get the active data connection on phone, when this happens Service fails to do HTTP post as there is no data connection. Is it possible for the Receiver to send the intent to Service using startService with a delay.? so that when onStartCommand of Service is called data connection is ready to post data.
View 2 Replies
View Related
Mar 30, 2009
How do you pass an intent from a service to a new activity launched from a main activity? There's a passextra( intent src ); but I don't think thats what I am looking for?
activity main > start service( intent wuteverserviceintent );
activity main > start activity( intent newactivityintent );
View 2 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
Aug 20, 2009
I am getting following message when i try to launch service.Also is there any specific path on file system where we need to place the .apk file which contains my serivce component only.
View 2 Replies
View Related
Nov 7, 2009
I have some code that is creating and removing alarms, and which works great in Android 1.5 and 1.6 but breaks on the Android 2.0 AVD.The code that's giving this exception is: Code...
View 3 Replies
View Related
Nov 14, 2010
I am developing an Android app and I am doing some heavy work (bringing data from an online web page and parsing it to store in database) in a service. Currently, it is taking about 20+ mins and for this time my UI is stuck. I was thinking of using a thread in service so my UI doesn't get stuck but it is giving error.
View 1 Replies
View Related
Sep 3, 2010
I have a launcher activity which gets activated everytime i start the application and a service which complements it. Now as i press the return key from my main activity .Its Ondestroy gets called.Now i have nullify the pointer of the my launcher activity there. now i am listening through the service any event happening on the network after closing the launcher activity thread and if any event occurs i have to relaunch my launcher activity. i have tried intent but doesnot seems to get though it .
View 4 Replies
View Related
Oct 6, 2010
I have a service (input method) and from within that service I want to start and activity which was declared in the same manifest. The activity maybe running but in the background.
How do i check its presence and bring it to front, or optionally start this.
From what I can gather from other posts, this is about what I need to do:
CODE:..............
I don't knwo which of thest flags pertain to what I need to do. The docs are quite merky, and my random attempt at making this work failed.
View 4 Replies
View Related
Oct 16, 2009
My application has a background process which continuously waits on a socket for receiving messages and it should be started only once and at the time of application starting.Thus i want to do that background job in a service.
The service should not be started from the activity ,it should be started at the application starting.
How can i define the service,which will be started at the time of application starting?
If at all the service is started from activity.The activity can be destroyed and restarted.when this happens the service also be restarted .
View 7 Replies
View Related
May 15, 2009
We have a service. bindService() returns true. But our ServiceConnection is never called with onConnect(). The onCreate() of the service is never executed (neither is the onBind(), of course).
Except sometimes! (twice now, out of many many tries).
Remote service, local service, intent-filter, direct class invocation, "procedure" attribute, no procedure attribute, cupcake, 1.1, emulator, device ... we've tried 'em all!
We belive the service is found, and in the remote case, we see the new process always created ... but the dang service just isn't started. We aren't specifying any security settings and writing the simplest manifest entry we can....
View 4 Replies
View Related
Jul 4, 2010
I am trying to start a service from the BroadcastReceiver, but I keep getting the startService line marked as an error:
CODE:............
View 2 Replies
View Related
Jan 14, 2010
I am having service inside a .apk file. I want to automatically start this service when this package is downloaded from the browser and installed. Is it possible to automatically start the service when the .apk file gets installed using some special intents.
I am right now using activity and broadcast recievers to start the service . But however, I would like to start the service automatically when the apk file gets installed with out writting activity or broadcast recievers.
View 2 Replies
View Related
Sep 4, 2009
My service is not in the same package namespace as my application / activities.
I have
CODE:...........
The issue is that my service is in -- package com.myco.service.myservice and my activity is in -- package com.myco.test.myactivity
My questions are:
1. does my service *have* to be in the com.myco.test namespace?
2. if it doesn't, how do I specify the android:name for my activity and my service to work?
View 8 Replies
View Related
Mar 13, 2009
I have moved some intensive processing from my main thread to a service. My UI is hanging and then crashing when I start the service, even if I put the service start in a new thread started via
Thread updateThread = new Thread(null, backgroundRefresh2, "new_thread"); updateThread.start();
What am I doing wrong? Also, it seems like the cause of the eventual crash in the service/worker thread doesn't show up in LogCat.
View 11 Replies
View Related
Apr 17, 2009
Is it possible to start a service directly from the launcher by clicking the application icon?
I have no activity just a single service which I want to start when I click on the icon, however when I specify my service's intent-filters it seems that it will not be recognised from the launcher, therefore no icon is visible in android's launcher.
CODE:............
How to get the icon into the launcher.
View 4 Replies
View Related