On Wed, Aug 11, 2010 at 9:50 AM, Markus Feuerstein <[email protected]> wrote: > Thanks for your quick answer. > If I understand right, I could solve it like this: > > @Override > public void onStart( Intent intent, int startId ){ > super.onStart( intent, startId ); > if( !mServiceRunning ) { > mServiceHandler = new Handler(); > mServiceHandler.post( mTask ); > mServiceRunning = true; > } > }
I have no idea what the purpose of the above code is. However, I really doubt you want to be using Handler and post() -- that will do your work on the main application thread. Most likely, you want to do your work on a background thread. Use AsyncTask or some background thread that you fork. Or, possibly, use IntentService, though I don't think those are designed to be bound to. > Is this the recommended way, to deal with remote services? That is impossible to answer in the abstract. It is like asking "which is the best motorized vehicle: a tank or a scooter?". If your goal is easy parking, a tank is the wrong choice. :-) An activity (or other client) can send work to a remote service via startService() or via bindService() and calling a method on the service's API. The client can get results back via bindService() and a listener object, or via a private broadcast, or via createPendingResult(), or via a ResultReceiver, or probably other mechanisms as well. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android 2.2 Programming Books: http://commonsware.com/books -- 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

