I have included pjsua2 in my android app. When sending an SMS message, the application crashes. It does not fall every time, it happens randomly. (every 10 posts).
MyCode:
public void sendInstantMessage(String number, String msgBody) { String buddy_uri = "<sip:" + number + "@" + mPref.getString(PREF_SIPSERVER, "") + ">"; Log.e(TAG, "sendInstantMessage ==== "+buddy_uri); BuddyConfig bCfg = new BuddyConfig(); bCfg.setUri(buddy_uri); bCfg.setSubscribe(false); MyBuddy im = new MyBuddy(bCfg); SendInstantMessageParam prm = new SendInstantMessageParam(); prm.setContent(msgBody); prm.setContentType("text/plain; charset=utf-8"); try { im.create(account, bCfg); boolean valid1 = im.isValid(); Log.e(TAG, "valid1 ======= "+valid1); im.sendInstantMessage(prm); } catch (Exception e) { Log.e(TAG, "sendInstantMessage ==== "+e); e.printStackTrace(); return; } }
According to logcat, I have to call pj_thread_register (). But I have a libRegisterThread () method at the endpoint, so I used it as shown below
MyApp.ep.libRegisterThread("SipApi");
Here is logcat:
../src/pj/os_core_unix.c:692: pj_thread_this: assertion "!"Calling pjlib from unknown/external thread. You must " "register external threads with pj_thread_register() " "before calling any pjlib functions."" failed
source share