1

I have implemented a simple sip call using Android Api SipManager. When i use default sip port 5060 (since i do not need to explicity mention it on code), it works well on both android 4.4 as well as android 7. But when I use other sip port like (5090), i have to explicity mentioned them in code. In that case i am able to create sip call only Android 4.4 (API 19 ), But refused to register for sip call on Android 7 with (API 24). Any help would be highly appreciated.

/*: makeSipProfile * Description: Instantiates the User's SipProfile and enables the app to * receive calls. */

private void makeSipProfile() {
    if (manager != null) {
        // Creates a SipProfile for the User
        try {
            SipProfile.Builder builder = new SipProfile.Builder(USERNAME, DOMAIN);
            builder.setPassword(PASSWORD);
            builder.setProtocol("UDP");    //explicitily mentioning sip port
            builder.setPort(5090);         // port 5090
            profile = builder.build();
            Log.e("$$", "SipProfile was built.");

            // Creates an intent to receive calls
            Intent intent = new Intent();
            intent.setAction("android.VOIPDEMO.INCOMING_CALL");
            PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, Intent.FILL_IN_DATA);
            manager.open(profile, pendingIntent, null);


            // Determines if the SipProfile successfully registered
            manager.setRegistrationListener(profile.getUriString(),
                new SipRegistrationListener() {

                    /**
                     * Name: onRegistering
                     * Description: Logs a status message indicating the
                     *              SipProfile is registering.
                     */
                    public void onRegistering(String localProfileUri) {
                        Log.e("$$", "Sip Profile <" + localProfileUri + " is registering");
                    }

                    /**
                     * Name: onRegistrationDone
                     * Description: Logs a status message indicating the
                     *              SipProfile successfully registered.
                     */
                    public void onRegistrationDone(String localProfileUri, long expiryTime) {
                        Log.e("$$", "Sip Profile <" + localProfileUri + "> successfully registered");
                        VoipActivity.setText(localProfileUri + " login successful");
                    }

                    /**
                     * Name: onRegistrationFailed
                     * Description: Logs a status message indicating the
                     *              SipProfile failed to register.
                     */
                    public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage) {
                        Log.e("$$", "Sip Profile failed to register <" + localProfileUri + "> " +
                                " Error message: " + errorMessage);
                        VoipActivity.setText(localProfileUri + " login unsuccessful. Error message:" + errorMessage);
                    }
                });
        } catch (ParseException e) {
            Log.e("$$", "SipProfile was not built.");
            e.printStackTrace();
        } catch (SipException e) {
            e.printStackTrace();
        }
    }
}
Tim
  • 367
  • 1
  • 12

0 Answers0