- Timestamp:
- Oct 18, 2012 8:36:13 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/android/pjsip-apps/src/apjsua/src/org/pjsip/pjsua/ApjsuaActivity.java
r4194 r4284 22 22 /* This class is for running pjsua in a secondary thread. */ 23 23 class PjsuaThread extends Thread { 24 public static Boolean finished; 24 public enum PjsuaState { 25 NULL, INITED, TERMINATED 26 }; 27 public static PjsuaState state; 25 28 26 29 public void run() { 27 if (pjsua_app.initApp() != 0) 28 return; 30 if (pjsua_app.initApp() != 0) { 31 state = PjsuaState.TERMINATED; 32 return; 33 } 34 state = PjsuaState.INITED; 29 35 30 36 pjsua_app.startPjsua(ApjsuaActivity.CFG_FNAME); 31 finished = true; 37 state = PjsuaState.TERMINATED; 38 39 try { 40 Thread.sleep(200); 41 } catch(Exception e) { 42 } 32 43 pjsua_app.deinitApp(); 33 44 } … … 42 53 43 54 protected Void doInBackground(Void... args) { 44 while (!PjsuaThread.finished) { 45 publishProgress(pjsua_app.getMessage()); 55 while (PjsuaThread.state != PjsuaThread.PjsuaState.TERMINATED) { 56 if (PjsuaThread.state == PjsuaThread.PjsuaState.INITED) 57 publishProgress(pjsua_app.getMessage()); 46 58 } 47 59 return null; … … 116 128 (keyCode == KeyEvent.KEYCODE_ENTER)) 117 129 { 118 pjsua_app.setInput(cmd.getText().toString()); 130 if (PjsuaThread.state == PjsuaThread.PjsuaState.INITED) 131 pjsua_app.setInput(cmd.getText().toString()); 119 132 cmd.setText(""); 120 133 return true; … … 136 149 137 150 /* Create pjsua and output thread */ 138 PjsuaThread. finished = false;151 PjsuaThread.state = PjsuaThread.PjsuaState.NULL; 139 152 TextOutTask outTask = new TextOutTask(); 140 153 outTask.tv = tv;
Note: See TracChangeset
for help on using the changeset viewer.