所有搜索完成以及所有这些。关于popupwindow上的错误令牌异常的许多问题。但没有解决这个问题。首先,有时它有效,有时它不起作用。这让事情变得更加复杂。
代码:
private void PopupWindowManagement(PopupWindow popup, boolean dismiss, boolean show, View view, int resource, int gravity, int OFFSET_X, int OFFSET_Y) {
int i;
boolean reinitialize = false;
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(contextPublic);
String shiftID = settings.getString("shift_id", "");
for(i = 0; i < 5; i++) {
try {
if (reinitialize) {
contextPublic = AantarnetClientActivity.this;
sendEmail("popup " + (show ? "show" : "dismiss") + " reinit 1 resource=" + resource + " i=" + i + " shift_id=" + shiftID + " plateNbr=" + plateNbr);
LayoutInflater layoutInflater = (LayoutInflater) contextPublic.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = layoutInflater.inflate(resource, new LinearLayout(contextPublic), false);
popup.setContentView(view);
sendEmail("popup " + (show ? "show" : "dismiss") + " reinit 2 resource=" + resource + " i=" + i + " shift_id=" + shiftID + " plateNbr=" + plateNbr);
}
if (show) {
if (popup != null && !popup.isShowing()) {
popup.showAtLocation(view, gravity, OFFSET_X, OFFSET_Y);
}
} else if (dismiss) {
if (popup != null && popup.isShowing()) {
popup.dismiss();
}
}
break;
} catch (Exception e) {
sendEmail("popup " + (show ? "show" : "dismiss") + " resource=" + resource + " i=" + i + " shift_id=" + shiftID + " plateNbr=" + plateNbr);
reinitialize = true;
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
sendEmail("popup " + (show ? "show" : "dismiss") + " sleep resource=" + resource + " i=" + i + " shift_id=" + shiftID + " plateNbr=" + plateNbr);
//e1.printStackTrace();
}
Log("hanna: DismissDialog=" + i);
}
}
if(i == 5) {
sendEmail("popup " + (show?"show":"dismiss") + " shift_id=" + shiftID + " plateNbr=" + plateNbr);
}
}
所以for循环是尝试5次,如果第一个失败,显然,这个代码发生一次,弹出窗口没有显示SOMETIMES。其他一些时候它只是工作并显示弹出窗口。
如您所见,我发布了一个在不同条件下发送电子邮件的功能,这里有一些电子邮件。 (如果没有例外,没有任何事情发生,没有发送电子邮件)
如果发生异常,请发送电子邮件:
EMAIL1:
version 1.8 message popup show resource=2130903048 i=0 shift_id=7471 plateNbr=380998
EMAIL2:
version 1.8 message popup show reinit 1 resource=2130903048 i=1 shift_id=7471 plateNbr=380998
有时我会收到email3:
version 1.8 message popup show reinit 2 resource=2130903048 i=1 shift_id=7471 plateNbr=380998
你可以看到我现在等于1,意味着它进入了if(重新初始化),但从未到达它的结尾,并且没有看到其他例外因为没有发送其他电子邮件,它只是没有显示弹出窗口。但由于我不能说的很多原因,我不能重新初始化整个弹出窗口
任何帮助或问题或进一步的信息,请告诉我。