| | |
| | | import android.content.Intent; |
| | | import android.graphics.Bitmap; |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | 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.service.HDLLinphoneService; |
| | | import com.hdl.hdllinphonesdk.utils.HDLLog; |
| | | |
| | | import org.linphone.core.Address; |
| | | import org.linphone.core.Call; |
| | | import org.linphone.core.CallParams; |
| | | import org.linphone.core.Core; |
| | | import org.linphone.core.ProxyConfig; |
| | | import com.hdl.hdllinphonesdk.dialog.LpTipDialog; |
| | | //import com.hdl.hdllinphonesdk.core.service.HDLLinphoneService; |
| | | //import com.hdl.hdllinphonesdk.utils.HDLLog; |
| | | // |
| | | //import org.linphone.core.Core; |
| | | //import org.linphone.core.ProxyConfig; |
| | | |
| | | public class MainActivity extends Activity { |
| | | private static final String TAG = "MainActivity"; |
| | | |
| | | private TextView mTextView,mTextView2,mTextView3,mTextView4; |
| | | private TextView mTextView, mMonitorText, mTextView3, mTextView4; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.activity_main); |
| | | |
| | | findViewById(R.id.mDialog).setOnClickListener(view -> { |
| | | new LpTipDialog(MainActivity.this, "sss", "ddd", new LpTipDialog.ClickListenerInterface() { |
| | | @Override |
| | | public void SureClick(LpTipDialog lpTipDialog) { |
| | | lpTipDialog.dismiss(); |
| | | } |
| | | |
| | | @Override |
| | | public void CancelClick(LpTipDialog lpTipDialog) { |
| | | lpTipDialog.dismiss(); |
| | | } |
| | | }).show(); |
| | | }); |
| | | mTextView = findViewById(R.id.tv_hello); |
| | | mTextView2 = findViewById(R.id.mTextView2); |
| | | mMonitorText = findViewById(R.id.mTextView2); |
| | | mTextView3 = findViewById(R.id.mTextView3); |
| | | mTextView4 = findViewById(R.id.mTextView4); |
| | | |
| | | mTextView.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | // startActivity(HDLLinphoneMonitorActivity.class); |
| | | // EasyLinphone.callTo("0000",true); |
| | | // EasyLinphone.setAccountAndLogin("44 EasyLinphone.setAccountAndLogin("4444", "85521566", "116.62.26.215:5060");44", "85521566", "116.62.26.215:5060"); |
| | | mTextView.setOnClickListener(v -> HDLLinphoneKit.getInstance() |
| | | .setAccountAndLogin( |
| | | "A583853817423247", |
| | | "763548", |
| | | "139.159.157.75:46000", |
| | | HDLLinphoneKit.INTER_PHONE_TYPE_FREEVIEW |
| | | )); |
| | | |
| | | // {"data": "{\"sipPassword\":\"8ec02ce0\",\"sipAccount\":\"61723164995710}} |
| | | // {"data": "{\"sipPassword\":\"cc6d73c1\",\"sipAccount\":\"61723164995779}} |
| | | // EasyLinphone.setAccountAndLogin("61723164995710", "8ec02ce0", "47.94.42.230:25060"); |
| | | // HDLLinphoneKit.getInstance().setAccountAndLogin("61723164995710", "8ec02ce0", "sipproxy.ucpaas.com:25060"); |
| | | mTextView4.setOnClickListener(v -> HDLLinphoneKit.getInstance().setAccountAndLogin("8888", "85521566", "47.96.88.250:35060", HDLLinphoneKit.INTER_PHONE_TYPE_FREEVIEW)); |
| | | |
| | | // 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"); |
| | | |
| | | |
| | | } |
| | | mMonitorText.setOnClickListener(v -> { |
| | | // String sip_account = "sip:D" + space_code + "@yun"; |
| | | HDLLinphoneKit.getInstance().callTo("sip:D22-1-21-1@139.159.157.75:46000", true); |
| | | // HDLLinphoneKit.getInstance().callTo("D22-1-21-1", true); |
| | | startActivity(HDLLinphoneMonitorActivity.class); |
| | | }); |
| | | |
| | | mTextView4.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | HDLLinphoneKit.getInstance().setAccountAndLogin("5555", "85521566", "test-gz.hdlcontrol.com:5060"); |
| | | } |
| | | mTextView3.setOnClickListener(v -> { |
| | | HDLLinphoneKit.getInstance().callTo("D22-1-21-1", true); |
| | | startActivity(HDLLinphoneMonitorActivity.class); |
| | | }); |
| | | |
| | | mTextView2.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | |
| | | 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) { |
| | | HDLLinphoneKit.getInstance().logout(); |
| | | } |
| | | }); |
| | | |
| | | //1.初始化SDK,并注册HDLLinphoneService |
| | | HDLLinphoneKit.getInstance().initLinphone(this); |
| | | //2.设置是否自动跳转呼叫,如果对接极光推送再弹出页面,这里要设置false |
| | | HDLLinphoneKit.getInstance().setAutoJumpCallView(true); |
| | | //3.监听呼叫和监控页面,用户操作的相关事件、接听、拒接、开锁等.... |
| | | setOnHDLLinphoneCallListener(); |
| | | mTextView.performClick(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 退出清空账号 |
| | | * enableRegister false |
| | | */ |
| | | public void logout() { |
| | | try { |
| | | Core core = HDLLinphoneService.getCore(); |
| | | 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();//从配置中删除所有代理。 |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void logoutLog() { |
| | | try { |
| | | Core core = HDLLinphoneService.getCore(); |
| | | ProxyConfig[] configs = core.getProxyConfigList(); |
| | | if(configs != null) { |
| | | HDLLog.E("registrationState账户length" + configs.length); |
| | | } |
| | | |
| | | for (ProxyConfig config : configs) { |
| | | HDLLog.E("registrationState账户"+config.getIdentityAddress().getUsername()); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | boolean isOpen; |
| | | boolean openSuccess; |
| | | void setOnHDLLinphoneCallListener(){ |
| | | HDLLinphoneKit.getInstance().setOnHDLLinphoneCallListener( new OnHDLLinphoneCallListener() { |
| | | |
| | | void setOnHDLLinphoneCallListener() { |
| | | HDLLinphoneKit.getInstance().setOnHDLLinphoneCallListener(new OnHDLLinphoneCallListener() { |
| | | @Override |
| | | public void onAnswerAction() { |
| | | showToast("接听"); |
| | | // EasyLinphone.toggleMicro(true); |
| | | } |
| | | |
| | | @Override |
| | | public void onRejectCallAction() { |
| | | showToast("拒接"); |
| | | // EasyLinphone.hangUp(); |
| | | } |
| | | |
| | | @Override |
| | | public void onUnlockAction() { |
| | | // showToast("开锁"); |
| | | // EasyLinphone.callTo("61723164995779",true); |
| | | openSuccess = !openSuccess; |
| | | if(openSuccess){ |
| | | HDLLinphoneKit.getInstance().onOpenSuccess(); |
| | | }else{ |
| | | HDLLinphoneKit.getInstance().onOpenError("设备不在线"); |
| | | } |
| | | |
| | | |
| | | // |
| | | } |
| | | |
| | | @Override |
| | | public void onHangUpAction(int callDuration) { |
| | | showToast("挂断 通话时长:"+callDuration); |
| | | // EasyLinphone.hangUp(); |
| | | showToast("挂断 通话时长:" + callDuration); |
| | | } |
| | | |
| | | @Override |
| | |
| | | showToast("截图"); |
| | | } |
| | | |
| | | @Override |
| | | public void onIncomingCall(String s) { |
| | | @Override |
| | | public void onIncomingCall(String s) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | |
| | | Intent intent = new Intent(this, clazz); |
| | | startActivity(intent); |
| | | } |
| | | |
| | | |
| | | |
| | | } |