Lutz Schönemann wrote:
> Hi,
>
> 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? My
> current solution is:
>
> new Thread() {
> @Override
> public void run() {
> // start Service
> Intent intent = new Intent("MyServiceAction");
> try {
> startService(intent);
> }
> catch(Exception e) {
> Log.e(TAG, "Unable to start Service: " +
> e.getMessage());
> }
> }
> }.start();
>
> It seems that the service is still in the same thread as my UI. The
> debugger doesn't show an additional thread. What am I doing wrong?
You don't want the service to be started in a background thread, because
there is no such concept. All Android components share a common primary
("UI") thread.
Instead, have the service start its own background thread and do its
work there.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
Need help for your Android OSS project? http://wiki.andmob.org/hado
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---