android - Code well executed with a menu, not with an AlertDialog button -


first of all, i'm developping sip application (in 2.3 android version). have menu button ends call, when tap on it, call ended , other peer disconnected. however, have alertdialog 2 buttons(in class)(yes , no answer call), , when tap on "no" call not ended menu button although it's excatly same code: menu button code:

public boolean onoptionsitemselected(menuitem item) {        case hang_up:                 if(call != null) {                     try {                       call.endcall();                     } catch (sipexception se) {                         log.d("walkietalkieactivity/onoptionsitemselected",                                 "error ending call.", se);                     }                     call.close();                     updatestatus("ready.");                 }                 break;         }         return true;  }  

alertdialog code:

ad.setnegativebutton("non",                  new onclicklistener(){                    public void onclick(dialoginterface dialog,                                       int arg1) {                       mt.stop();                       sipcommunicator wtactivity2 = (sipcommunicator) context;                      if(call != null) {                           try {                             call.endcall();                          } catch (sipexception se) {                               log.d("impossible de terminer l'appel",                                      "error ending call.", se);                          }                           call.close();                          wtactivity2.updatestatus("ready.");                   }                  }                }); 

what problem ? thank much.


Comments