我必须把《守则》放在后面,以理解我想要说的话:
public void répondre()
{
mt = MediaPlayer.create(context,R.raw.ringtone);
mt.setVolume(5,5);
mt.start();
mt.setLooping(true);
//startActivity((new Intent(Intent.ACTION_ANSWER)));
AlertDialog.Builder ad = new AlertDialog.Builder(context);
ad.setTitle("Appel en cours...");
ad.setMessage("Voulez vous répondre à cet appel?");
ad.setPositiveButton("Oui",
new OnClickListener() {
public void onClick(DialogInterface dialog,
int arg1) {
mt.stop();
SipAudioCall incomingCall = null;
try {
SipAudioCall.Listener listener = new SipAudioCall.Listener() {
@Override
public void onRinging(SipAudioCall call, SipProfile caller) {
try {
call.answerCall(30);
} catch (Exception e) {
Log.d("Call not answered","Call not answered",e);
}
}
};
SIPCommunicator wtActivity = (SIPCommunicator) context;
incomingCall = wtActivity.manager.takeAudioCall(intent, listener);
incomingCall.answerCall(30);
incomingCall.startAudio();
incomingCall.setSpeakerMode(true);
if(incomingCall.isMuted()) {
incomingCall.toggleMute();
}
wtActivity.call = incomingCall;
String useName = wtActivity.call.getPeerProfile().getDisplayName();
wtActivity.updateStatus("Vous êtes en communication avec " + useName);
} catch (Exception e) {
if (incomingCall != null) {
incomingCall.close();
}
}
}
});
I want to show the caller s name(useName
variable) in the AlertDialog. If i put this line(String useName = wtActivity.call.getPeerProfile().getDisplayName();
) before MediaPlayer
and make ad.setTitle("Appel en cours"+useName);
the variable useName
is null
! So how doing this ?
Thank you very much.