Add parameter to LinphoneService to choose which activity to launch when incoming call

This commit is contained in:
Sylvain Berfini 2012-06-06 13:25:04 +02:00
parent 334288b1fc
commit 4d21042082
2 changed files with 17 additions and 6 deletions

View file

@ -53,6 +53,8 @@ public class LinphoneLauncherActivity extends Activity {
} }
protected void onServiceReady() { protected void onServiceReady() {
LinphoneService.instance().setActivityToLaunchOnIncomingReceived(LinphoneActivity.class);
startActivity(new Intent() startActivity(new Intent()
.setClass(this, LinphoneActivity.class) .setClass(this, LinphoneActivity.class)
.setData(getIntent().getData())); .setData(getIntent().getData()));

View file

@ -35,6 +35,7 @@ import org.linphone.core.Log;
import org.linphone.core.OnlineStatus; import org.linphone.core.OnlineStatus;
import org.linphone.mediastream.Version; import org.linphone.mediastream.Version;
import android.app.Activity;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
@ -86,7 +87,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
/** /**
* @throws RuntimeException service not instantiated * @throws RuntimeException service not instantiated
*/ */
static LinphoneService instance() { public static LinphoneService instance() {
if (isReady()) return instance; if (isReady()) return instance;
throw new RuntimeException("LinphoneService not instantiated yet"); throw new RuntimeException("LinphoneService not instantiated yet");
@ -242,6 +243,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
private Object[] mSetForegroundArgs = new Object[1]; private Object[] mSetForegroundArgs = new Object[1];
private Object[] mStartForegroundArgs = new Object[2]; private Object[] mStartForegroundArgs = new Object[2];
private Object[] mStopForegroundArgs = new Object[1]; private Object[] mStopForegroundArgs = new Object[1];
private Class<? extends Activity> incomingReceivedActivity = LinphoneActivity.class;
void invokeMethod(Method method, Object[] args) { void invokeMethod(Method method, Object[] args) {
try { try {
@ -438,7 +440,17 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
}); });
} }
} }
public void setActivityToLaunchOnIncomingReceived(Class<? extends Activity> activity) {
incomingReceivedActivity = activity;
}
protected void onIncomingReceived() {
//wakeup linphone
startActivity(new Intent()
.setClass(this, incomingReceivedActivity)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
public void onCallStateChanged(final LinphoneCall call, final State state, final String message) { public void onCallStateChanged(final LinphoneCall call, final State state, final String message) {
if (instance == null) { if (instance == null) {
@ -446,10 +458,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
return; return;
} }
if (state == LinphoneCall.State.IncomingReceived) { if (state == LinphoneCall.State.IncomingReceived) {
//wakeup linphone onIncomingReceived();
startActivity(new Intent()
.setClass(this, LinphoneActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} }
if (state == State.CallUpdatedByRemote) { if (state == State.CallUpdatedByRemote) {