android 開啟執行緒查詢資料,耗時操作
阿新 • • 發佈:2018-12-31
try { final Handler handler = new Handler(); final Runnable callBack = new Runnable() { public void run() { try { //執行緒結束,處理 } catch (Exception ex) { ex.getStackTrace(); } } }; final Thread thread = new Thread() { @Override public void run() { try { //耗時操作 } catch (Exception ex) { } handler.post(callBack); } }; thread.start(); } catch (Exception ex) { }