Ignore:
Timestamp:
Feb 16, 2018 9:37:00 AM (6 years ago)
Author:
nanang
Message:

Misc (#2059): Update Android & Java app samples to avoid call instance deletion in the library callback context (thanks Kai Ludwig for the feedbacks).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/swig/java/android/app/src/main/java/org/pjsip/pjsua2/app/MainActivity.java

    r5649 r5738  
    233233        } else if (m.what == MSG_TYPE.CALL_STATE) { 
    234234 
    235             CallInfo ci = (CallInfo) m.obj; 
    236  
    237             /* Forward the message to CallActivity */ 
    238             if (CallActivity.handler_ != null) { 
     235            MyCall call = (MyCall) m.obj; 
     236            CallInfo ci; 
     237            try { 
     238                ci = call.getInfo(); 
     239            } catch (Exception e) { 
     240                ci = null; 
     241            } 
     242 
     243            /* Forward the call info to CallActivity */ 
     244            if (ci != null && CallActivity.handler_ != null) { 
    239245                Message m2 = Message.obtain(CallActivity.handler_, 
    240246                    MSG_TYPE.CALL_STATE, ci); 
    241247                m2.sendToTarget(); 
     248            } 
     249 
     250            if (ci != null && 
     251                ci.getState() == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED) 
     252            { 
     253                call.delete(); 
    242254            } 
    243255 
     
    602614            ci = null; 
    603615        } 
    604         Message m = Message.obtain(handler, MSG_TYPE.CALL_STATE, ci); 
     616        Message m = Message.obtain(handler, MSG_TYPE.CALL_STATE, call); 
    605617        m.sendToTarget(); 
    606618 
Note: See TracChangeset for help on using the changeset viewer.