meghabachani
Lurker
I have developed a sip client receiver where in the code is as follows:
When I place the code of receive call method in onReceive method, intent is not null, but this way it is null. I want the receivecall method to get executed on click of a button, whereas if this code is onReceive method, the call will be taken without clicking on button. please guide me whether where am i wrong.
Code:
public class IncomingCallReciever extends BroadcastReceiver {
public SipAudioCall call=null;
public Intent myintent;
Caller newcall;
MediaPlayer ourSong;
//IncomingCallReciever obj=new IncomingCallReciever();
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
newcall=(Caller)context;
myintent=intent;
Intent startActivity=new Intent();
startActivity.setClass(context, Reciever.class);
startActivity.setAction(IncomingCallReciever.class.getName());
startActivity.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_NEW_TASK & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
context.startActivity(startActivity);
}
public void receiveCall(){
try {
SipAudioCall.Listener listener=new SipAudioCall.Listener(){
public void onRinging(SipAudioCall call, SipProfile caller) {
try {
call.answerCall(30);
} catch (Exception e) {
e.printStackTrace();
}
}
};
call=newcall.manager.takeAudioCall(myintent, listener);
call.answerCall(200);
call.startAudio();
call.setSpeakerMode(true);
newcall.call=call;
}catch(SipException ex)
{
ex.printStackTrace();
}
if(call!=null){
call.close();
}
}