1
HTTPPost를 사용하여 값을 서버에 보내고 있습니다. 스크립트는 아래에있는 것과 잘 작동합니다. 나는이에 이름 값 쌍을 변경하지만 경우에 나는 가까운 힘을 얻을 : 내 댓글이 대답처럼안드로이드 NameValuePair가 문자열을 받아들이지 않음
String url_select = "http://mydomain.com/get.php";
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url_select);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("id", "1"));
try {
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
//read content
is = httpEntity.getContent();
} catch (Exception e) {
Log.e("log_tag", "Error in http connection "+e.toString());
}
try {
BufferedReader br = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = "";
while((line=br.readLine())!=null){
sb.append(line+"\n");
}
is.close();
result=sb.toString();
} catch (Exception e) {
Log.e("log_tag", "Error converting result "+e.toString());
}
return null;
logcat의 오류는 무엇입니까? 또한,'idOfTextView'가 null이 아닌지 확인하십시오. – wsanville
발생 원인 : java.lang.NullPointerException> 06-14 15 : 27 : 36.606 : E/AndroidRuntime (29275) : com.sample.sampleapp.viewRandom $ task.doInBackground (viewRandom.java:78) 줄 78은 다음과 같습니다. 이름값 쌍을 설정하려고하는 선. –
그런 다음 idOfTextView가 null이거나 idOfTextView.getText()가 null 인 경우 오류 로그 – Guardanis