java - Besides AsyncTask, is there anyway in Android to do something on the UI thread from another thread? -
because strange reasons, when use asynctask connect webpage, ui of app lags point of freezing while asynctask connecting webpage.
i thought because connection takes quite long, @ least 4 seconds.
i want able update textview after thread have finished, how do in android besides using asynctask?
there few methods that:
- use threads or runnables
- use handlers, sending messages its
- use runonuithread method
- use method (this favorite) post. it's not necessary use context/activity instance
for example, can create new handler() , when want run code in main thread do:
public static handler interfacehandler = new handler(); ... minterfacehandler.post(new runnable() { @override public void run() { //your stuff } });
to complete information, views in android can make post(runnable) . method add runnable task do, reason recommendable not use views because app slow down. static handler perfect make work , easy implement
Comments
Post a Comment