This is a complete solution, and it should work fine. Some methods will only run on uithread, (runOnUiThread is an activity method, so if you cannot reach it, just put a variable
private final Activity activity = this;
and call runOnUiThread from there
public void TestMethod() { Test= new Thread(new Runnable() { public void run() { try{ Catch(); } catch (Exception ioe) {
}
source share