我在编写Android应用程序时遇到Eclipse问题..
如果我处于调试模式并逐行浏览我的代码,则会收到错误消息“找不到来源”。
这是我的代码:
public boolean checkVersion(){
httpclient = new DefaultHttpClient();
httppost = new HttpPost("http://"+this.ip+"/fastorder/android/checkDatabaseVersion.php"); // make sure the url is correct.
try{
String db_vers = String.valueOf(DATABASE_VERSION);
//add your data
nameValuePairs = new ArrayList<NameValuePair>();
// Always use the same variable name for posting i.e the android side variable name and php side variable name should be similar,
nameValuePairs.add(new BasicNameValuePair("version", db_vers)); // $Edittext_value = $_POST['Edittext_value'];
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
//Execute HTTP Post Request
//response = httpclient.execute(httppost);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String response = httpclient.execute(httppost, responseHandler);
System.out.println("Response: " + response);
if(response.equalsIgnoreCase("true")){
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
// set title
alertDialogBuilder.setTitle("Speisekarte aktualisieren?");
// set dialog message
alertDialogBuilder
.setMessage("Wollen Sie jetzt die aktuelle Version der Speisekarte downloaden?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
loadUpdate();
}
})
.setNegativeButton("No",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, just close
// the dialog box and do nothing
dialog.cancel();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
else if(response.equalsIgnoreCase("false")){
}
}catch(ClientProtocolException e){
Log.e("FastOrder", "Exception : " + e);
}catch(IOException e){
Log.e("FastOrder", "Exception : " + e);
}
return true;
}
错误显示在:String response = httpclient.execute(httppost, responseHandler);
行...
有人有答案吗?我试着解决这个问题,因为几天......
答案 0 :(得分:0)
这是因为无法找到您尝试访问的方法的源代码。
尝试在出现错误的行按[F6]。