• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Sip Client Reciever provides intent value as null

I have developed a sip client receiver where in the code is as follows:
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();
            }
        }
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.
 
Back
Top Bottom