注册未运行Android Sip错误

时间:2017-04-27 08:34:51

标签: android call sip sip-server opensips

美好的一天。 我正在尝试打开已预先注册的sip配置文件。 如果我从Google Play下载任何其他SIP应用程序,该配置文件将完全正常工作,但当我尝试在我的代码中初始化时,我在打开配置文件时收到错误registration not running

Accordingly i was following this post for the answers, but seems the owner don't remember how he had fixed the issue -.-

无论如何,这里是我如何初始化和打开已注册的SIP配置文件的代码。

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_SIP) != PermissionChecker.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.USE_SIP}, 0);
    }

    initSip();
}

private void initSip() {
    if (mSipManager == null) {
        mSipManager = SipManager.newInstance(this);
    }
}

public void closeLocalProfile() {
    if (mSipManager == null) {
        return;
    }
    try {
        if (mSipProfile != null) {
            mSipManager.close(mSipProfile.getUriString());
        }
    } catch (Exception ee) {
        ee.printStackTrace();
        Log.d("faskjlfas", "Failed to close local profile.", ee);
    }
}

点击后,我打开这样的本地档案。

  @OnClick(R.id.login)
public void loginClciked() {
    closeLocalProfile();

    profile = null;
    try {
        profile = new SipProfile.Builder(usernameEd.getText().toString(), "sip2sip.info");
    } catch (ParseException e) {
        e.printStackTrace();
    }
    profile.setPassword(passwordED.getText().toString());
    mSipProfile = profile.build();

    Intent intent = new Intent();
    intent.setAction("android.SipDemo.INCOMING_CALL");
    final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, Intent.FILL_IN_DATA);

    try {
        mSipManager.open(mSipProfile, pendingIntent, new SipRegistrationListener() {
            @Override
            public void onRegistering(String localProfileUri) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        updateStatus("Registering with SIP Server...");
                    }
                });
            }

            @Override
            public void onRegistrationDone(String localProfileUri, long expiryTime) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        updateStatus("Ready");
                    }
                });
            }

            @Override
            public void onRegistrationFailed(String localProfileUri, int errorCode, final String errorMessage) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        updateStatus("Registration failed.  Please check settings." + errorMessage);
                    }
                });
            }
        });
    } catch (SipException e) {
        e.printStackTrace();
    }
}

但如上所述,正在使用消息onRegistrationFailed触发registration not running回调。所以任何帮助都将不胜感激。

0 个答案:

没有答案
相关问题