Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid sip not receiving any calls
    primarykey
    data
    text
    <p>I'm unable to receive any calls on my android SIP application, I can register successfully with the SIP server, I can initiate call and invite other users successfully but I can't receive any calls. I don't think I have anything wrong in my SIP server or my devices as I'm able to use Sipdroid application and initiate and receive calls.</p> <p>My code is as follows, which is based on SipDemo example:</p> <pre><code>public class WalkieTalkieActivity extends Activity implements View.OnTouchListener { public static final String TAG = "WalkieTalkieActivity"; public String sipAddress = null; public SipManager manager = null; public SipProfile me = null; public SipAudioCall call = null; public IncomingCallReceiver callReceiver; private static final int CALL_ADDRESS = 1; private static final int SET_AUTH_INFO = 2; private static final int UPDATE_SETTINGS_DIALOG = 3; private static final int HANG_UP = 4; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.walkietalkie); ToggleButton pushToTalkButton = (ToggleButton) findViewById(R.id.pushToTalk); pushToTalkButton.setOnTouchListener(this); // Set up the intent filter. This will be used to fire an // IncomingCallReceiver when someone calls the SIP address used by this // application. IntentFilter filter = new IntentFilter(); filter.addAction("android.SipDemo.INCOMING_CALL"); callReceiver = new IncomingCallReceiver(); this.registerReceiver(callReceiver, filter); // "Push to talk" can be a serious pain when the screen keeps turning off. // Let's prevent that. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 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(manager == null) { manager = SipManager.newInstance(this); } initializeLocalProfile(); } /** * Logs you into your SIP provider, registering this device as the location to * send SIP calls to for your SIP address. */ public void initializeLocalProfile() { if (manager == null) { return; } if (me != null) { closeLocalProfile(); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String username = prefs.getString("namePref", "XXX"); String domain = prefs.getString("domainPref", "192.168.1.11"); 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.setOutboundProxy(domain); builder.setPort(8090); builder.setProtocol("UDP"); me = builder.build(); Log.d(TAG, "Auto Registration: " + me.getAutoRegistration()); Log.d(TAG, "SipProfile: " + me.getUriString()); Intent i = new Intent(); i.setAction("android.SipDemo.INCOMING_CALL"); PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, Intent.FILL_IN_DATA); manager.open(me, pi, null); Log.d(TAG, "manage.isOpen() " + manager.isOpened(me.getUriString())); // This listener must be added AFTER manager.open is called, // Otherwise the methods aren't guaranteed to fire. manager.setRegistrationListener(me.getUriString(), new SipRegistrationListener() { public void onRegistering(String localProfileUri) { updateStatus("Registering with SIP Server..."); } public void onRegistrationDone(String localProfileUri, long expiryTime) { updateStatus("Ready"); Log.d(TAG,"Registration done successfully....."); Log.d(TAG,"Local Profile URI: " + me.getUriString()); Log.d(TAG,"Local Profile URI: " + me); } public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage) { updateStatus("Registration failed. Please check settings. " + errorMessage); } }); } catch (ParseException pe) { updateStatus("Connection Error."); } catch (SipException se) { updateStatus("Connection error."); } } /** * Closes out your local profile, freeing associated objects into memory * and unregistering your device from the server. */ public void closeLocalProfile() { if (manager == null) { return; } try { if (me != null) { manager.close(me.getUriString()); } } catch (Exception ee) { Log.d("WalkieTalkieActivity/onDestroy", "Failed to close local profile.", ee); } } /** * Make an outgoing call. */ public void initiateCall() { updateStatus(sipAddress); 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(); updateStatus(call); } @Override public void onCallEnded(SipAudioCall call) { updateStatus("Ready."); } }; Log.d(TAG,"Calling: " + sipAddress); call = manager.makeAudioCall(me.getUriString(), sipAddress, listener, 30); } catch (Exception e) { Log.i("WalkieTalkieActivity/InitiateCall", "Error when trying to close manager.", e); if (me != null) { try { manager.close(me.getUriString()); } catch (Exception ee) { Log.i("WalkieTalkieActivity/InitiateCall", "Error when trying to close manager.", ee); ee.printStackTrace(); } } if (call != null) { call.close(); } } } } public class IncomingCallReceiver extends BroadcastReceiver { public static final String TAG = "IncomingCallReceiver"; /** * Processes the incoming call, answers it, and hands it over to the * WalkieTalkieActivity. * @param context The context under which the receiver is running. * @param intent The intent being received. */ @Override public void onReceive(Context context, Intent intent) { Log.d(TAG,"************************* Incoming call received....."); SipAudioCall incomingCall = null; try { SipAudioCall.Listener listener = new SipAudioCall.Listener() { @Override public void onRinging(SipAudioCall call, SipProfile caller) { try { call.answerCall(30); } catch (Exception e) { e.printStackTrace(); } } }; WalkieTalkieActivity wtActivity = (WalkieTalkieActivity) context; incomingCall = wtActivity.manager.takeAudioCall(intent, listener); incomingCall.answerCall(30); incomingCall.startAudio(); incomingCall.setSpeakerMode(true); if(incomingCall.isMuted()) { incomingCall.toggleMute(); } wtActivity.call = incomingCall; wtActivity.updateStatus(incomingCall); } catch (Exception e) { if (incomingCall != null) { incomingCall.close(); } } } } &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.android.sip" android:versionCode="1" android:versionName="1.0" &gt; &lt;application android:icon="@drawable/icon" android:label="SipDemo"&gt; &lt;activity android:name=".WalkieTalkieActivity" android:configChanges="orientation|keyboardHidden"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN"/&gt; &lt;category android:name="android.intent.category.LAUNCHER"/&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".SipSettings" android:label="set_preferences"/&gt; &lt;receiver android:name=".IncomingCallReceiver" android:label="Call Receiver"/&gt; &lt;/application&gt; &lt;uses-sdk android:minSdkVersion="9" /&gt; &lt;uses-permission android:name="android.permission.USE_SIP" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;uses-permission android:name="android.permission.VIBRATE" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt; &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt; &lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt; &lt;uses-feature android:name="android.hardware.sip.voip" android:required="true" /&gt; &lt;uses-feature android:name="android.hardware.wifi" android:required="true" /&gt; &lt;uses-feature android:name="android.hardware.microphone" android:required="true" /&gt; &lt;/manifest&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload