我已经使用 AlertDialog 查看了有关此问题的所有帖子,但均无济于事。有人能看出这里有什么不对吗?我尝试了 DialogFragment,但我从 PhoneStateListener 执行此操作,无法扩展其他任何内容。我没有空令牌,所以 getBaseContext 正在工作。我相信。
private void lookupCallerId(int cstate)
{
if(prefs.getIsDeactivated())
return;
if(lookupInProgress)
{
return;
}
//add popup box here for lookup question?
PMLog.v(LOGTAG, "lookupCallerId() Start pop up box.");
Context context = service.getBaseContext();
if(cstate == TelephonyManager.CALL_STATE_RINGING) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
PMLog.v(LOGTAG, "lookupCallerId() ALERT BUILDER.");
builder.setTitle("Lookup this #?");
builder.setCancelable(true);
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String strPhoneNumber = PhoneNumberProcessor.formattedPhoneNumber(prefs.getLastCallerNumber(), service); {
if(strPhoneNumber.length() == 0)
return;
}
PMLog.v(LOGTAG, "lookupCallerId() Starting CNM lookup thread");
Thread thread = new Thread(null, doBackgroundThreadProcessing, "LookupBackgroundThread");
thread.start();
}
}
);
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
onNo();
return;
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
onNo();
return;
}
});
builder.create().show();
}
}