Android音频调用使用android的sip

Android音频调用使用android的sip,第1张

概述我为客户开发了一个使用sip进行互联网呼叫的应用程序.因为他为我提供了两个有效的sipuser_id和密码.我正在使用SIPAPI进行SIP实现.客户表示呼叫没有进行.当他使用他的账号登录时,他没有得到关于未接来电的任何通知.我无法找到代码中的任何错误.请帮助我.代码是如下.publicclas

我为客户开发了一个使用sip进行互联网呼叫的应用程序.因为他为我提供了两个有效的sip user_ID和密码.我正在使用SIP API进行SIP实现.客户表示呼叫没有进行.当他使用他的账号登录时,他没有得到关于未接来电的任何通知.我无法找到代码中的任何错误.请帮助我.代码是如下.

public class CallActivity extends Activity {        public String sipAddress = null;        public SipManager mSipManager = null;        public SipProfile mSipProfile = null;        public SipAudioCall call = null;        button b1;        TextVIEw sipadd;        @OverrIDe        protected voID onCreate(Bundle savedInstanceState) {            // Todo auto-generated method stub            super.onCreate(savedInstanceState);            setContentVIEw(R.layout.calling);            sipAddress = (String) getIntent().getExtras().get("sipAddress");            b1 = (button) findVIEwByID(R.ID.sipcallbtnend);            b1.setonClickListener(new OnClickListener() {                @OverrIDe                public voID onClick(VIEw v) {                    finish();                }            });            sipadd = (TextVIEw) findVIEwByID(R.ID.sipcalltvdialedaddress);            sipadd.setText(sipAddress);            b1.setonClickListener(new OnClickListener() {                @OverrIDe                public voID onClick(VIEw v) {                    if (call != null) {                        call.close();                    }                    finish();                }            });            initializeManager();        }        @OverrIDe        public voID onStart() {            super.onStart();            // When we get back from the preference setting Activity, assume            // settings have changed, and re-login with new auth info.            initializeManager();        }        @OverrIDe        public voID onDestroy() {            super.onDestroy();            if (call != null) {                call.close();            }            closeLocalProfile();            // if (callreceiver != null) {            // this.unregisterReceiver(callreceiver);            // }        }        public voID initializeManager() {            if (mSipManager == null) {                mSipManager = SipManager.newInstance(this);            }            initializeLocalProfile();        }        public voID initializeLocalProfile() {            if (mSipManager == null) {                return;            }            if (mSipProfile != null) {                closeLocalProfile();            }            SharedPreferences prefs = PreferenceManager                    .getDefaultSharedPreferences(getBaseContext());            String username = prefs.getString("namePref", "");            String domain = prefs.getString("domainPref", "");            String password = prefs.getString("passpref", "");            if (username.length() == 0 || domain.length() == 0                    || password.length() == 0) {                // showDialog(UPDATE_SETTINGS_DIALOG);                return;            }            try {                SipProfile.Builder builder = new SipProfile.Builder(username,                        domain);                builder.setPassword(password);                builder.setdisplayname(username);                builder.setAuthUsername(username);                mSipProfile = builder.build();                Intent i = new Intent();                i.setAction("androID.SipDemo.INCOMING_CALL");                PendingIntent pi = PendingIntent.getbroadcast(this, 0, i,                        Intent.FILL_IN_DATA);                mSipManager.open(mSipProfile, pi, null);                //                //                // // This Listener must be added AFTER manager.open is called,                // // Otherwise the methods aren't guaranteed to fire.                mSipManager.setRegistrationListener(mSipProfile.getUriString(),                        new SipRegistrationListener() {                            public voID onRegistering(String localProfileUri) {                                // updateStatus("Registering with SIP Server...");                                Log.d("onRegistering",                                        "Registering with SIP Server...");                            }                            public voID onRegistrationDone(String localProfileUri,                                    long expiryTime) {                                // updateStatus("Ready");                                Log.d("onRegistrationDone",                                        "RegistrationDone..Ready");                            }                            public voID onRegistrationFailed(                                    String localProfileUri, int errorCode,                                    String errorMessage) {                                // updateStatus("Registration Failed.  Please check settings.");                                Log.d("onRegistrationFailed", "RegistrationFailed");                            }                        });            } catch (ParseException pe) {                // updateStatus("Connection Error.");            } catch (SipException se) {                // updateStatus("Connection error.");            }            initiateCall();        }        public voID closeLocalProfile() {            if (mSipManager == null) {                return;            }            try {                if (mSipProfile != null) {                    mSipManager.close(mSipProfile.getUriString());                }            } catch (Exception ee) {                Log.d("WalkIETalkIEActivity/onDestroy",                        "Failed to close local profile.", ee);            }        }        public voID initiateCall() {            // updateStatus(sipAddress);            Log.d("nzm", "initiatecall");            try {                SipAudioCall.Listener Listener = new SipAudioCall.Listener() {                    // Much of the clIEnt's interaction with the SIP Stack will                    // happen via Listeners. Even making an outgoing call, don't                    // forget to set up a Listener to set things up once the call is                    // established.                    @OverrIDe                    public voID onCallEstablished(SipAudioCall call) {                        call.startAudio();                        call.setSpeakerMode(true);                        call.toggleMute();                        Log.d("on call established", "on call established");                        // updateStatus(call);                    }                    @OverrIDe                    public voID onCallEnded(SipAudioCall call) {                        // updateStatus("Ready.");                        // Intent i = new                        // Intent(getBaseContext(),DialActivity.class);                        // startActivity(i);                        finish();                    }                };                call = mSipManager.makeAudioCall(mSipProfile.getUriString(), sipAddress,                        Listener, 3000);                Log.d("call", "" + call.getState());            } catch (Exception e) {                Log.i("WalkIETalkIEActivity/InitiateCall",                        "Error when trying to close manager.", e);                if (mSipProfile != null) {                    try {                        mSipManager.close(mSipProfile.getUriString());                    } catch (Exception ee) {                        Log.i("WalkIETalkIEActivity/InitiateCall",                                "Error when trying to close manager.", ee);                        ee.printstacktrace();                    }                }                if (call != null) {                    call.close();                }            }        }    }

清单中的权限如下所示

<uses-permission androID:name="androID.permission.USE_SIP" />    <uses-permission androID:name="androID.permission.INTERNET" />    <uses-permission androID:name="androID.permission.VIBRATE" />    <uses-permission androID:name="androID.permission.ACCESS_WIFI_STATE" />    <uses-permission androID:name="androID.permission.WAKE_LOCK" />    <uses-permission androID:name="androID.permission.RECORD_AUdio" />    <uses-feature androID:name="androID.harDWare.sip.voip" androID:required="true" />    <uses-feature androID:name="androID.harDWare.wifi" androID:required="true" />    <uses-feature androID:name="androID.harDWare.microphone" androID:required="true" />

请帮帮我.谢谢.

解决方法:

也许添加这些

<uses-permission androID:name="androID.permission.CONfigURE_SIP" /><uses-feature androID:name="androID.software.sip" androID:required="true" /><uses-feature androID:name="androID.software.sip.voip" androID:required="true" /><uses-feature androID:name="androID.harDWare.telephony" androID:required="false" />

你在使用androID的例子吗?它应该在支持SIP的设备上工作.

并在onCreate中添加接收器

IntentFilter filter = new IntentFilter();filter.addAction("androID.SipDemo.INCOMING_CALL");callreceiver = new Incomingcallreceiver();this.registerReceiver(callreceiver, filter);
总结

以上是内存溢出为你收集整理的Android音频调用使用android的sip全部内容,希望文章能够帮你解决Android音频调用使用android的sip所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1110390.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存