如果互聯網網絡較低,服務器端響應時間超過1分鐘,我需要顯示一個對話框。如何完成這項任務。 我正在使用下面的代碼。 但它不工作故意.:Android:等待服務器響應一分鐘,否則顯示警告對話框
try
{
HttpConnectionParams.setConnectionTimeout(hc.getParams(),60000);
int timeoutSocket = 60*1000;
HttpConnectionParams.setSoTimeout(hc.getParams(), timeoutSocket);
}
catch(ConnectTimeoutException e){
//System.out.println(e);
m_Progress.cancel();
alertDialog = new AlertDialog.Builder(AdminEbooks.this).create();
//alertDialog.setTitle("Reset...");
// System.out.println("internet not available");
alertDialog.setMessage("Low internet connectivity?");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
alertDialog.cancel();
}
});
}
我檢查這一點,也沒有工作..它只是顯示一個黑色的屏幕沒有別的:( – ekjyot
哎neetesh其工作,但u能PLZ告訴我的其他因爲當我的w/s進度dailog運行,然後我得到兩個日誌從w/s。1)爲我的登錄響應和2)形式URL url = new URL(「http:// ....... ..........「);所以我的w/s檢查Url兩次,並顯示日誌兩次。 – Google