Я должен опубликовать код, чтобы понять, что я хочу сказать:
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();
}
}
}
});
Я хочу показать имя вызывающего абонента (useName
переменная) в AlertDialog.Если я поставлю эту строку (String useName = wtActivity.call.getPeerProfile().getDisplayName();
) перед MediaPlayer
и сделаю ad.setTitle("Appel en cours"+useName);
, то переменная useName
будет null
!Так как это сделать?Большое спасибо.