Android :: Running Listeners In Separate Threads
Aug 25, 2009
I would like to know how to run a listener on an isolated thread. Because I would like to use a LocationListener and make some calculations in the main thread. So the LocationListener would be "slow down", because of those calculations. Is it possible to have it run in a different thread? Or is it by default in a separate thread?
View 2 Replies
Jun 24, 2010
I have two questions about sensor listeners
1. from which thread are sensor values updated and should this be synchronized? can sensor's listener callback be a good place to call custom's view onDraw method? as this should be done from different thread. I cant find anything about it. In another words my problem is that I want to listen to sensors change and draw something on view surface but I dont know which thread (the main thread of the application?) is updating sensor's state
2. If I register sensor listener with SENSOR_DELAY_FASTEST my application is not responsive at all! Raw application with TextView only is not reacting to go back or home button! How should I deal with this or am I doing something wrong?
View 4 Replies
View Related
May 21, 2009
My application starts a remote service and binds to it. If I close the application with the "back" button there are still some threads running (listed in the Debug View of Eclipse) - main thread, and three Binder threads. In onDestroy() I call unbindService(service_connection) - is there something else to clean up?
View 4 Replies
View Related
Sep 2, 2009
Making separate service app and separate activity app. swapnil kamble
- Hide quoted text -
View 2 Replies
View Related
Apr 13, 2010
What are the advantages/disadvantages in placing a lengthy network access code in a thread in an activity or a thread in a service? How would it affect the application? I am writing a streaming audio player and from what I've read so far putting the code in a service will still end up blocking the application so a new thread is needed, does anyone know if it makes more sense to put this piece of code in a service.
View 1 Replies
View Related
Sep 14, 2010
Can I have one Activity listen for a message from another?I have a TabActivity and I need to call a function/send a message to the associated tabs.How do I go about doing that?
View 9 Replies
View Related
Nov 24, 2010
I want to implement an Android Service that periodically downloads data and notifies various listener activities that the data has been updated.
There seems to be various way of communicating with a Service. What's the simplest and best way to do the above?
View 2 Replies
View Related
May 24, 2010
I have following code:
CODE:...........
Code is working but here goes my problem: when I call it from main activity in this way:
CODE:........
Then i can see 10 times result of 'doing sth else!!!' and when loop is over i can see then result from activity. So sensor activity waits for some reason and then when main activity has nothing to do, sensors are doing their job.
of course I have well implemented: onActivityResult(int requestCode, int resultCode, Intent intent)
I want to read sensord data directly, not using listeners, is it possible?
View 1 Replies
View Related
Mar 22, 2009
Is there a way to check before sending a broadcast (from a remote service) whether there are registered broadcast listeners? What I'd like to do is to send broadcasts only if there are registered listeners, otherwise make a toast. Does it make any sense?
View 3 Replies
View Related
Jan 6, 2010
I have touched on this question here, where Christopher gave an answer to this, but I dont really get it so I thought its time to make it a real question, not just a "follow up" =)
As it stands, the application Im writing has 4 different screens:
1. Screen 1 - list of nodes (main screen)
2. Screen 2 - options menu, tableLayout with buttons
3. Screen 3 - navigation
4. Screen 4 - text details on version etc
These screens can be navigated to/from using a "header" View that is placed on top. the header then has 4 different buttons:
+--------------------+
| menu with buttons |
+--------------------+
| |
| |
| |
| C O N T E N T |
| |
| |
| |
+--------------------+
The header is just an XML-file (header.xml) with a few buttons. That header.xml is the included in the Layouts using the include-markup. For example, the main.xml has the line:
<include layout="@layout/header"></include>
The header show up alright, but the question is - what is the correct approach to attach OnClickListeners for the buttons in the header?
Christopher pointed out that you could create an Activity class and do the hooks there, like this:
CODE:............
First, I cant make it work since the method setupHeaderButtons isnt accessible from FirstActivity.
Secondly, is this the right way to go at it?
View 3 Replies
View Related
Jun 28, 2010
I have an app that has two buttons one for email & one for SMS. Depending on the button pressed I want to email or else SMS a certain text. I have coded the email button and it is working fine. The problem is that the dialog box that pops-up gives an option of e-mail or Messaging the text. I want to separate out the two, so that when the user presses email, only the options of email is there, and when the user presses SMS, only the option of Messaging is there.
View 1 Replies
View Related
Nov 4, 2010
I have read all about having separate processes for different Application components, and how to use them.I am curious, what are some appropriate use cases for when an application should actually use separate processes?It seems to me, the main advantage to using separate processes is to make the different portions of your app more easily killable by the OS.
View 7 Replies
View Related
Oct 22, 2010
We 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.
View 4 Replies
View Related
Apr 6, 2010
I am working on a simple application (studying purposes) which list all the files from a selected folder. On top of that I would like to have a search feature where the user can search for files (the code for that is already in place). Now, I was thinking about having the search running in the background somehow, whilst the user can still navigate, create folders, copy, sort and do other stuffs normally. When the search finishes the user would get a notification and then could click on it and go to that activity (It ideally should be the same ListView I already use for browsing the files, I would just need to update the Adapter there with the latest processed data after clicking in the notification). What's the best answer for that? Threading or AsyncTask?
View 4 Replies
View Related
Feb 22, 2010
I'm trying to understand the idea behind the Services. If it runs in the program's thread, why not create just a separate thread (or AsyncTask) to do the job? Can a service keep running in the background? For example, i want to create a task that will continuously be polling data from a server, even if the main application is not running. Can this be achieved with a Service?
View 8 Replies
View Related
Mar 13, 2010
while debugging and app that uses AsyncTask to record audio and update UI I noticed that everytime that an AsyncTask object ends running (finishes doInBackground and onPostExecute or on Cancelled it´s thread stays alive (running status).At least for me that should not be the behavior of the class since the doInBackground task may not stay running forever (as an example the android manual says that a status bar should be updated by an asynctask, and it won´t last for the whole app running time).Is there anything I´m missing, as a method to destroy it, or should I just ignore and keep creating threads as I need and the VM will handle them as it needs resources?
View 9 Replies
View Related
Jun 5, 2010
how do i save certain threads?
View 1 Replies
View Related
Aug 3, 2010
As my app matures, I find myself finding more and more uses for threads. By now I must have about 25 threads, all doing important things and working together in symphony.
I notice however that my app is sitting around 15.5MB resident. Compared to the browser (+/-35MB) I feel pretty safe, but I do notice the resident size of my app ever increasing.
The question is, how much overhead is involved with adding a thread?
I'm also wondering if the synchronized keyword encounters more and more latency with each new thread that is present?
View 4 Replies
View Related
Jun 28, 2010
I have a project that builds against Android v2.1 . I can run it fine on a phone running 1.5 but when I try to launch it with an emulator running 1.5, the emulator doesn't show up on the list of available AVDs. I have the <uses-sdk android:minSdkVersion="3"/> tag in my manifest but it doesn't make a difference.
View 2 Replies
View Related
Aug 19, 2009
I am trying to get the list of process running in the background.
View 4 Replies
View Related
Jul 27, 2009
i have a little frontend showing a list of items that it will retrieve from a service. I want that service to be started in a separate thread.so the UI is still responding to user interaction while waiting for that service to call a callback method. What is the best way to start the service in a detached thread?
View 6 Replies
View Related
Mar 15, 2010
Being interested in Android development and still in the experimentation phase - there's something I haven't been able to grasp. As far as I've been able to understand, the process lifecycle and application lifecycles are separate and as such, it would be possible for the application to still to exist, even if it's process has been killed. So I guess my question would be, in what scenario could this occur and how is the application accessible if the containing process has been killed?
View 5 Replies
View Related
Jun 28, 2010
I would like to define each tab's content in a different XML file so the visual editor in Eclipse can be used. That is, without all of the tabs being laid over each other. The visual editor doesn't even seem to work with the XML example provided here: [link text][1]
[1]: http://developer.android.com/guide/tutorials/views/hello-tabwidget.html "Here", It just has a Null pointer exception.
I have tried to define each tap in it's own file, for example. code...
And when adding the tab I use:
mTabHost.addTab(mTabHost.newTabSpec("tab_in").setIndicator("Input").setContent(R.layout.input));
But this causes the application to crash on launch. Is there any way to do this?
View 4 Replies
View Related
Mar 20, 2010
I want to set a menu option icon for a drawable that is in another jar inside an xml file. code...
Instead of drawable/my_location have something like com.somelib.R.drawable.someDrawable.
I can set this in onCreateOptionsMenu but was just wondering if it could be done via the xml file.
View 1 Replies
View Related
Nov 24, 2010
I'm currently developing an Android application, but I'd like to be able to handle button click events etc in a separate file for each Activity. Is this possible? At the moment, I have one very large file that handles all events for several Activity windows.
View 2 Replies
View Related
Apr 7, 2014
I want to have TWO calendar apps on my devices (Samsung S4 and Samsung Galaxy Tablet) such that one syncs all my personal (Google) calendars and the other syncs my work (Outlook) calendar. It is not visually useful to sync in one calendar (use 7 personal calendars - 6 family members plus group family calendar). Is it possible to setup calendar views independently across two or more calendar apps?
View 3 Replies
View Related
Mar 4, 2010
I have an activity that uses a Timer (java.util.Timer) to control the display. I set it off to repeat its run() method every second or so. When it runs, it updates some View elements.
As Timer runs in its own thread, I assumed this would be reliable. But I notice that sometimes there is a stutter, or delay, in the views updating. It's like they occasionally get stacked up, and all happen together. Studying the output from logcat, I notice that this happens when the device is doing something else - some system functions, or sometimes a garbage collection.
How can I avoid this? I'm not aware I can run the main activity in a thread of its own, can I? If the timer has its own thread, why is it affected?
View 8 Replies
View Related
Nov 17, 2009
We are developing an application that needs to suspend and resume threads like a debugger (meaning in a non-safe way like Object.wait() and Object.notify()).In the Java SDK the methods Thread.suspend() and Thread.resume() are deprecated but we can still use them. Also there is the Java debugger API which allows one to do that if you connect to the VM as a debugger. Is there some API for android we can use? Is there a published Java Debugger API we can apply for Android?
View 2 Replies
View Related
Oct 30, 2009
I have a question about the background thread handling change that went into SDK 1.6. I read here that BG threads get placed in a scheduling class that can't use more than 5-10% of the CPU in order to keep the foreground responsive. Do system services get into that scheduling class?
My app uses repeating alarms. It was great with 1.5, very reliable. Since the upgrade to 1.6, the phone seems to be dropping some of my repeating broadcasts, especially if I am doing something fun in the foreground like with WIFI when the Alarm is supposed to fire. I do not have any of the task killer programs that have been a hot topic lately. To be clear, the dropped alarm broadcast behavior is intermittent. I am not 100% sure if I really am doing something when it has failed. If the timer is a one shot, it seems to work better but there is no real empirical evidence here. My phone is usually in my pocket when I fire one of the one shot alarms. If my theory about system services in the background scheduling class is correct, then I probably cannot find a workaround or defensively code a solution. Will it be the same in 2.0?
Have others seen issues with alarms and with the setRepeating method? I am looking for suggestions to troubleshoot this problem. How can I determine if the problem is the broadcast, if it is the repeating alarm creation, or if there is some other issue like low memory coming in to play.
View 13 Replies
View Related
Mar 4, 2010
I have a couple of worker threads in my app which I stop and restart during onPause() and onResume(). I use a method that clears all the reference to and from the threads when stopping. However ThreadGroup is still retaining a reference to my threads and causing a small memory leak. After pausing and resuming my app about 40 to 50 times I will then get OutOfMemory Errors when loading bitmaps. Allthough this doesn't effect most of my users I do get occasional reports of crashes. How can I remove the references to my threads from ThreadGroup so that GC can do it's job.
View 4 Replies
View Related