Update UI or toast from IntentService : What will happen if you try to touch U I or try to print a toast message from onHandleIntent() function of IntentService class ?

Answer:  it behaves weirdly, either toast message may not appear or it appears and will be n
ever removed. this happens because other thread is touch ui with out informing to
main thread.If you try to touch other UI components, it will crash.


Description:
it behaves weirdly, either toast message may not appear or it appears and will be never removed. this happens because other threads can't touch UI with out informing to main thread. If you try to touch other UI components, it will crash. IntentService onHandleIntent() functions runs in worker thread (not main thread). So don't try to touch UI elements from that function directly.

No comments:

Post a Comment