Android :: How To Set Priority Of IntentService?
Sep 1, 2010I was wondering if it is possible to set the priority of an IntentService like you can with a Thread. So far I have not found anything.
View 1 RepliesI was wondering if it is possible to set the priority of an IntentService like you can with a Thread. So far I have not found anything.
View 1 RepliesWe are in the process of refitting some of our recievers and services with IntentServices (mostly to address rare ANR issues - and because IntentService is pretty cool...). In one case we are converting a traditional service to an IntentService. The original service fired off a few methods whose job was to download data from our servers. Each of these requests would spawn a thread of their own to do the work (apparently not fast enough to avoid the occasional ANR). So now we have a question concerning the life cycle of these processes.
For example, the following situation demonstrates what is happening:
- Start Intent Service - Trigger Download1 - Download 1 thread starts - End Intent Service
- Download 1 thread continues..... - Download 1 thread ends
Our question concerns our exposure to the OS shutting down the Download 1 thread because the Intent Service has terminated before it finishes up. Not sure if it is becomes more or less likely that the OS will view it as something that can be flushed.
If the Download 1 thread is more likely to be flushed by OS we will need to take a different approach.
I have to process some events given by a broadcast receiver. As kindly suggested by Mark M. a week ago, I am trying to send the intent to an intentservice in order to pass the data to be processed to another thread.
Looking at the doc, I can read abot onHandleIntent: "Only one Intent is processed at a time, but the processing happens on a worker thread that runs independently from other application logic. So, if this code takes a long time, it will hold up other requests to the same IntentService, but it will not hold up anything else.
What does it mean? Will the intents be queued and then processed one by one, or does it mean that the startService will block if the intentService is busy processing a previous intent?
And more (this is just my curiosity): What is the point in having a onStartCommand method in IntentService if the Intents must be processed in "onHandleIntent"?
The new IntentService in Android 1.5 looks excellent for handling AlarmManager-initiated broadcasts for scheduled WAKEUP work...except I can't see that it uses a WakeLock anywhere, either in itself or Looper/MessageQueue.
Does this implicitly hold a WakeLock that I'm not seeing? Or would I need to create a WakingIntentService that has an active WakeLock so long as there are messages in the queue?
If it must implement with AIDL? And please kindly provide an example. There are several solutions, Does anyone know which is better?
View 1 Replies View RelatedI have an IntentService that handles button callbacks from a widget. When the user presses a certain button, I want to display a Toast. I return from onHandleIntent almost immediately after doing Toast.show(), which in turn stops the service and kills its thread, which keeps the Toast from actually being displayed.
Can anyone suggest an easy way to get the Toast (or something similar) to display from an IntentService?
I have an IntentService that downloads some files. The problem is that I create a Toast inside the IntentService like this
Toast.makeText(getApplicationContext(), "some message", Toast.LENGTH_SHORT).show();
The Toast will never disappear event if I exit the app. The only way to destroy it is to kill the process.
What am I doing wrong?
I was searching for the priority implementation in Messaging. I didn't find any code to show the priority of say SMS( For ex: urgent SMS). Anyone knows whether this feature exists in Android. Or is there any plan to add show the message priority in the notification bar(For SMS /MMS/ Voicemail)
View 2 Replies View RelatedI have two apps that use a service to upload and download files and data. I've noticed that when the service gets very busy, it can cause the UI to block, up to the point that Android shows a "force quit/ wait" popup. In order to avoid that, I run tasks in a service at a lower priority. This way, the service will never cause the UI to hickup. Also, the service stops if the app hasn't been used for a certain number of minutes. I don't want to keep resources if the user isn't using my app.I have found that some of my users run apps that run services permanently at normal priority. Such a service starts at phone switch on, and keeps running indefinitely, downloading vast amounts of data. My policy of being nice to other apps doesn't pay off: these agressive third party services push my service away so it never gets anything done. As one of my users told me, my app has hickups, until he kills the service of this app X, after which my app runs smoothly, snappy, and fast.
My question is, should I be nice to other apps and to the UI in my own app, or should I just run a service and agressively take all resources I need - or don't need? This is one issue where Android is different from iPhone. We can run services, but by doing so, we can cause damage to other peoples apps. Of course, my "question" doesn't require an answer. I'm just curious after what other people think, what your experience here is.
Let me say this with an example. Lets say, my activity A is being executed, meanwhile another activity B gets launched. By default, acivity B will come on top of activity A. My requirement is that I want to keep A on top. Only activities such as phone, lock screen and home screen can come on top of me not other activities unless my activity closes.
View 5 Replies View RelatedIs there a standard way in Android to create an unkillable service with very high priority, assuming you have complete access to the device (as in you're building your own device on something like a beagleboard, not just installing an app)? I'm playing around with sip phone stuff, and it seems like just doing it as an app isn't going to work if you want high voice quality. (Assuming you want to be able to let the user switch away from the actual sip app and use different apps; all the sip phones I've tried have failed to maintain decent audio if you're multitasking.) Or would you just run the phonecall software outside Android in a normal Linux process and communicate with Android apps over sockets?
View 2 Replies View RelatedI am a newbie to Android so please excuse me if this is a silly question or one that has been answered many times before. When connecting to and using the Internet, I am trying to find out what determines the connection that the phone will use when more than one connection is available: Wifi, 3G etc. Is there a standard priority order for connection and use? can the user set the priority order? Usually I would expect the wifi connection to be preferred for reasons of speed and cost. I have looked at my phone user guide and the official Android user guide but cannot find any information about this.
View 4 Replies View RelatedThe symptom: I have a broadcast receiver that listen to sms, when a sms is received, i call an activity to display. It works all fine if the screen is on and not locked. But when screen is locked, and as soon as i received the sms, the activity popup for a second then disappeared and I use the code to unlock the screen.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
I think it might be the competitions with phone default sms program (the sms default program shows a notification only). I am wondering is there a way to set priority to broadcast receivers or even the activity that receiver stared, to avoid the conflicts between multiple receivers. or set orders to execute one by one? I have tried to thread.sleep my receiver for a second, still not working.
So from what I've known, if I do an AsyncTask inside an Activity, the task may be killed when user quits the Activity before it is finished. One solution I've seen is using IntentService, which the system will try hard not to kill. My problem is that IntentService only uses one background thread to run all the tasks one by one. I have several independent tasks that I wish to run concurrently, and that makes a difference in the UI (not serious, but could surprise user). How do I accomplish this? I imagine I could have several IntentService but this seems awkward and not scalable. How do I maintain sort of a threadpool that has a good priority, so that it won't get killed to easily by the system? If I start a (normal) Service, then launch some AsyncTasks within there, does that result in a higher priority?
View 1 Replies View RelatedDoes anyone know how to set it so that my Android phone only notifies me when I get a message in my "Priority Inbox" (the new feature Google just launched in case you don't know what it is)?With my email I receive a bunch of newsletters, so instead of being notified every time one of them arrives I'd like to be notified only when messages in my Priority Inbox arrive.Being able to be alerted to messages with certain labels only would also work.
View 8 Replies View RelatedI have an app which within the main Activity a SensorListener is setup. The listener detects changes from the accelerometer and sends updates to various child views, which update the display. When the app first start up, it's great - the graphics are smooth and the sensor notifications are immediately reflected in the views. Then after a few minutes it starts to stutter, making the display very jerky - and for the purpose of this app quite unusable. I've done some logging and the sensor updates are still being passed, but they start stacking up and all get sent in batches. It's like the system has put this app down the priority list after it's been running a while. I've added some garbage collecting but it only seemed to help a little. What could be happening here? How can I try and keep this app at the top of the priority list?
View 3 Replies View RelatedI have few question in application side. Questions are below 1. Can LMK (Low Memory Killer) kill service ? 2. Can I open multiple instance of same applications ? 3. Can I set the priority for the application? 4. LMK kills application(process) or one activity(suppose in application 4 activity). If it can kill activity then how activity stack handling this.
View 3 Replies View RelatedI am programming a game with fast graphics. The MediaPlayer is stuttering sometimes. When I have the MediaPlayer in a service, it does not stutter, but some people here adviced me not to use services if they should stop automatically when the user ends my application. So how can I set the thread-priority of the MediaPlayer-Object? SoundPool uses the MediaPlayer and with SoundPool, you can set the thread-priority, but I cannot add my audio-file to SoundPool, because its size is about 2mb (too big for SoundPool). I can lower my main-thread-priority so that the MediaPlayer has a relatively higher priority, but isn't this a bad idea?
View 2 Replies View RelatedI have developed a music player and the application defines a broadcast receiver that handles MediaButton intents:
<application...>
<receiver android:name="MediaButtonIntentReceiver"> <intent-filter android:priority="32000"> <action android:name="android.intent.action.MEDIA_BUTTON"/> </intent-filter> </receiver>
</application>
which works well. My question is if it was possible to change the priority of this receiver from within the settings activity of my application. That way people could choose if they wanted my player as default handler of the headset buttons or not.
I have a multithreaded streaming app which has mainly the following 5 threads. 1 Main App(UI) Thread 1 controller thread (in native) 1 audio decoder thread (in native) 1 video decoder thread(in native) 1 thread to query the head position of audio (in Java) Apart from this I have video rendering with OpenGL. My problem is, if I query the thread priority using the Thread.getPriority method (my native threads make callbacks to Java and I am making the query at that point of time), I am getting the priority of each of them as 5. For my audio query thread (the last one in the list) I am explicitly setting the priority using Process.setThreadPriority(Process.THREAD_PRIORITY_URGENT_AUDIO); Also for my decoder threads, I am giving higher priority than my controller thread(using pthread APIs in native). But still finally all of them seem to have same priority. Also what should I be doing to increase the priority of my threads(both from Java and native)?
View 6 Replies View RelatedI am trying to to use WiFi API to set priorities to created profiles. I am using the priority field of WifiConfiguration to set this information. I have found out that no matter what priority I set, Android always tries to re-connect to the latest access point that it was connected to. Here is what I do: 1) I create a profile A with a very low priority (0) 2) I create a profile B with high priority (100) 3) I connect to profile A 4) I turn Wi-Fi off 5) I turn Wi-Fi back on 6) In the scan Android sees both A & B 7) Android connects to A, even though its priority is much lower. Does anyone has a work around for this?
View 2 Replies View RelatedI have got myself an HTC Desire as my Orange upgrade. The tariff is really good for me and I'm blown away by how good the phone is. I have been using an iPhone for work and asides from the games on the application store, the Desire is just so much better. So I'm working my way slowly through these threads. Anything I should do as a priority now that I have my new handset.
View 3 Replies View RelatedSitting at home . WiFi in full operation and showing as such on the Desire. If I use my Desire what will it prioritise: My home WiFi connection or the ISP's data connection? Both have strong signals everywhere in the house and both are equally fast. Important to know as don't want any isp billing surprises!
View 7 Replies View RelatedI have 2 Access Points in my house broadcasting 2 different SSIDs, my Droid can connect to both successfully but it likes the one that is farthest away better. Most of the time I have to force connect the one I�m sitting next too. Is there a way to set a priority on which AP it connects too?
View 16 Replies View RelatedRemember when choosing your minutes was the single most important thing on your cell plan? Then slowly, texting options became more important? Now, with smartphones everywhere, I see the Data Plan as the most important option. As for me, when I see the incredible, I see so much more than just a phone. For me, the phone part seems more like a tacked on feature in that the device is so much more capable than a mere phone. With its constant connection to the internet and its ability to run apps ranging from anything to everything you can imagine, the Incredible seems to fully capture the term 'Personal Computer'. Of course, having minutes to talk on your phone is important, but is that slowly becoming less and less a priority? With the availability of Skype and other VoIP services, could cell phone plan minutes be a thing of the past in the not to distant future?
View 25 Replies View RelatedSo there are a few apps which I want staying in memory. I.E. I don't want Android to kill it. Is there such an app that can do this and if not, is there a script? I believe Super Charger? If Super Charger, how do I use it?
To summarize, I want a few apps (the phone, the messaging, true caller, and ex dialer) to get highest priority/never die.
Is this possible?
I read somewhere that iPhone UI is so smooth because the thread which renders the UI has the REALTIME priority... so is that possible to mod android's UI thread priority?
View 2 Replies View RelatedI want to link a few of my contacts with facebook so that I pull facebook info and get their profile pic. I know how to do this. However, I'd prefer to keep the name I already have for them on my phone. For example: Say I have "Jon" saved on my phone. His facebook profile name is Jon McJonjon. When I link the profiles, now his contact will read Jon McJonjon. I'd prefer to keep the name I previously had for him as his contact name. Any way to prioritize which profile you're linking is the main contact name that shows up under the contacts list?
View 1 Replies View RelatedIs there any way to change the priority in what picture gets displayed for the contacts? I have most of my contacts in Outlook via. Exchange, G-mail and facebook. I would like the picture to change along with their facebook picture but it seems to stay the pict i have in gmail or outlook. Is there a way to have it always show the facebook picture first and then if they arent a facebook contact fall back to the g-mail or outlook picture?
View 4 Replies View RelatedI have a hotmail.co.uk account set up on the HTC mail app with a widget on my home screen. The only problem with this its that i receive emails straight away i can access any attachments and view the majority of them which is great, however when i try to send, it attempts then after a minute or so it comes up unable to send mail. i have tried changing the priority of these emails for high to low but have no luck. My settings are:
incoming
Protocol: POP
POP server: pop3.live.com
security type: SSL
server port: 995
Outgoing
SMTP server: hotmail.co.uk
Security type: SSL
server port: 465