Hi,
Has anyone had any luck with SipManager. I have been playing around
with the sipdemo and I have created simple application. The
application creates SIPManager object and attempts to connect using
SipProfile to sip2sip.info.
But manager, api and voip are not supported.
This doesn't work either from the phone or the emulator.
Thanks in advance,
Graham
package gb.org;
import java.text.ParseException;
import android.app.Activity;
import android.net.sip.*;
import android.os.Bundle;
import android.util.Log;
import android.widget.EditText;
import android.widget.Toast;
public class gbsip extends Activity {
public SipManager manager = null;
public SipProfile me = null;
//temporary sip settings
public String name = "gbwien";
public String domain = "sip2sip.info";
public String password = "h7eefbtcff";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//this.apiSupport = (EditText) findViewById(R.id.api);
//this.voipSupported = (EditText) findViewById(R.id.voip);
initializeManager();
}
//CREATE A NEW SIP MANAGER INSTANCE
public void initializeManager() {
if(manager == null) {
manager = SipManager.newInstance(this);
Toast.makeText(gbsip.this, "Manager supported " +
manager.isApiSupported(this), Toast.LENGTH_LONG).show();
Toast.makeText(gbsip.this, "VOIP supported " +
manager.isVoipSupported(this), Toast.LENGTH_LONG).show();
}
initializeLocalProfile();
}
//LOG INTO SIP ACCOUNT USING A SIP PROFILE LOCAL TO THE
//DEVICE
public void initializeLocalProfile() {
if (manager == null) {
Toast.makeText(gbsip.this, "manager is null ",
Toast.LENGTH_LONG).show();
return;
}
if (me != null) {
closeLocalProfile();
}
try {
SipProfile.Builder builder = new
SipProfile.Builder(name, domain);
builder.setPassword(password);
me = builder.build();
Toast.makeText(gbsip.this, "SIP Registration
successful .... ",
Toast.LENGTH_LONG).show();
// Otherwise the methods aren't guaranteed to
fire.
manager.setRegistrationListener(me.getUriString(), new
SipRegistrationListener() {
public void onRegistering(String localProfileUri)
{
Toast.makeText(gbsip.this, "Registrating with
SIP Server.... ", Toast.LENGTH_LONG).show();
}
public void onRegistrationDone(String
localProfileUri, long expiryTime) {
Toast.makeText(gbsip.this, "Ready ",
Toast.LENGTH_LONG).show();
}
public void onRegistrationFailed(String
localProfileUri, int errorCode,
String errorMessage) {
Toast.makeText(gbsip.this, "SIP Registration
error .... ", Toast.LENGTH_LONG).show();
}
});
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(gbsip.this, "SIP Registration
error .... ",
Toast.LENGTH_LONG).show();
} catch (SipException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(gbsip.this, "SIP Exception has
occurred .... ",
Toast.LENGTH_LONG).show();
}
}
//END OF initializeLocalProfile
public void closeLocalProfile() {
if (manager == null) {
return;
}
try {
if (me != null) {
manager.close(me.getUriString());
}
} catch (Exception ee) {
Log.d("failed ", "Failed to close local profile.",
ee);
}
}
}
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="gb.org"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/
app_name">
<activity android:name=".gbsip"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="10"/>
<uses-permission android:name="android.permission.USE_SIP"/>
<uses-permission android:name="android.permission.INTERNET"/>
<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"/>
</manifest>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en