| | |
| | | import com.hdl.hdllinphonesdk.HDLLinphoneKit; |
| | | import com.hdl.hdllinphonesdk.activity.HDLLinphoneMonitorActivity; |
| | | import com.hdl.hdllinphonesdk.callback.OnHDLLinphoneCallListener; |
| | | import com.hdl.hdllinphonesdk.core.EasyLinphone; |
| | | //import com.hdl.hdllinphonesdk.core.EasyLinphone; |
| | | import com.hdl.hdllinphonesdk.core.service.HDLLinphoneService; |
| | | import com.hdl.hdllinphonesdk.utils.HDLLog; |
| | | |
| | | import org.linphone.core.Address; |
| | | import org.linphone.core.Call; |
| | |
| | | public class MainActivity extends Activity { |
| | | private static final String TAG = "MainActivity"; |
| | | |
| | | private TextView mTextView,mTextView2,mTextView3; |
| | | private TextView mTextView,mTextView2,mTextView3,mTextView4; |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | |
| | | mTextView = findViewById(R.id.tv_hello); |
| | | mTextView2 = findViewById(R.id.mTextView2); |
| | | mTextView3 = findViewById(R.id.mTextView3); |
| | | |
| | | mTextView4 = findViewById(R.id.mTextView4); |
| | | |
| | | mTextView.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | |
| | | // HDLLinphoneKit.getInstance().setAccountAndLogin("61723164995710", "8ec02ce0", "sipproxy.ucpaas.com:25060"); |
| | | |
| | | // HDLLinphoneKit.getInstance().setAccountAndLogin("5555", "85521566", "116.62.26.215:5060"); |
| | | // HDLLinphoneKit.getInstance().setAccountAndLogin("5555", "85521566", "test-gz.hdlcontrol.com:5060"); |
| | | // HDLLinphoneKit.getInstance().setAccountAndLogin("6666", "85521566", "test-gz.hdlcontrol.com:5060"); |
| | | |
| | | HDLLinphoneKit.getInstance().setAccountAndLogin("7777", "85521566", "test-gz.hdlcontrol.com:5060"); |
| | | // |
| | | // HDLLinphoneKit.getInstance().setAccountAndLogin("8888", "85521566", "test-gz.hdlcontrol.com:5060"); |
| | | // |
| | | // HDLLinphoneKit.getInstance().setAccountAndLogin("4444", "85521566", "test-gz.hdlcontrol.com:5060"); |
| | | |
| | | |
| | | } |
| | | }); |
| | | |
| | | mTextView4.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | HDLLinphoneKit.getInstance().setAccountAndLogin("5555", "85521566", "test-gz.hdlcontrol.com:5060"); |
| | | |
| | | |
| | | |
| | | } |
| | | }); |
| | | |
| | | mTextView2.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | // HDLLinphoneKit.getInstance().callTo("61723164995779",true); |
| | | // HDLcallTo("61723164995779",true); |
| | | HDLcallTo("1427186301744910338",true); |
| | | startActivity(HDLLinphoneMonitorActivity.class); |
| | | |
| | | logoutLog(); |
| | | return; |
| | | //// HDLLinphoneKit.getInstance().callTo("61723164995779",true); |
| | | //// HDLcallTo("61723164995779",true); |
| | | // HDLLinphoneKit.getInstance().callTo("1427186301744910338",true); |
| | | // startActivity(HDLLinphoneMonitorActivity.class); |
| | | |
| | | |
| | | } |
| | | }); |
| | | |
| | | mTextView3.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | logout(); |
| | | HDLLinphoneKit.getInstance().logout(); |
| | | } |
| | | }); |
| | | |
| | | HDLLinphoneKit.getInstance().initLinphone(this); |
| | | HDLLinphoneKit.getInstance().setAutoJumpCallView(true); |
| | | setOnHDLLinphoneCallListener(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 退出清空账号 |
| | | * enableRegister false |
| | | */ |
| | | public void logout() { |
| | | try { |
| | | Core core = HDLLinphoneService.getCore(); |
| | | ProxyConfig[] configs = core.getProxyConfigList(); |
| | | for (ProxyConfig config : configs) { |
| | | if (config != null) { |
| | | config.edit(); |
| | | config.enableRegister(false); |
| | | config.done(); |
| | | if (core != null) { |
| | | ProxyConfig[] configs = core.getProxyConfigList(); |
| | | for (ProxyConfig config : configs) { |
| | | if (config != null) { |
| | | config.edit(); |
| | | config.enableRegister(false); |
| | | config.done(); |
| | | } |
| | | } |
| | | core.clearAllAuthInfo();//清除所有认证信息。 |
| | | // core.clearProxyConfig();//从配置中删除所有代理。 |
| | | } |
| | | // core.clearAllAuthInfo(); |
| | | // core.clearProxyConfig(); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public Call HDLcallTo(String userName, boolean isVideoCall) { |
| | | Call call = null; |
| | | Core core = HDLLinphoneService.getCore(); |
| | | Address addressToCall = core.interpretUrl(userName); |
| | | CallParams params = core.createCallParams(null); |
| | | public void logoutLog() { |
| | | try { |
| | | Core core = HDLLinphoneService.getCore(); |
| | | ProxyConfig[] configs = core.getProxyConfigList(); |
| | | if(configs != null) { |
| | | HDLLog.E("registrationState账户length" + configs.length); |
| | | } |
| | | |
| | | if (isVideoCall) { |
| | | params.enableVideo(true); |
| | | params.enableLowBandwidth(false); |
| | | } else { |
| | | params.enableVideo(false); |
| | | for (ProxyConfig config : configs) { |
| | | HDLLog.E("registrationState账户"+config.getIdentityAddress().getUsername()); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | if (addressToCall != null) { |
| | | call = core.inviteAddressWithParams(addressToCall, params); |
| | | } |
| | | |
| | | return call; |
| | | } |
| | | |
| | | |
| | | boolean openSuccess; |
| | | void setOnHDLLinphoneCallListener(){ |
| | |
| | | public void onScreenshotSuccessfulAction(Bitmap image) { |
| | | showToast("截图"); |
| | | } |
| | | }); |
| | | |
| | | @Override |
| | | public void onIncomingCall(String s) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |