mcn.nice
دوشنبه 16 آذر 1394, 15:16 عصر
سلام خسته نباشید دوستان عزیز ، من چند روزی میشه که به یک مشکل خوردم و نمی تونم حلش کنم می خواستم از دوستانیکه می توانند کمکم کنند .
بنده یک برنامه ایجاد کردم که داده هاشو از اینترنت باید دریافت کنه (برنامه برای نمایش اطلاعات سایت) برنامه زمانیکه یک رشته ساده را از اینترنت می فرستم درست عمل میکنه و نمایش میده ولی نمیدونم چرا زمانیکه آرایه ای حاوی رشته ها را می خواهد بفرستد مقدار خالی را نمایش می دهد !!
اینم کد دریافت اطلاعات از سرور :
try {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("action", "نرم افزار"));
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params);
entity.setContentEncoding(HTTP.UTF_8);
entity.setContentType("application/json");
httpPost.setEntity(entity);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
final StringBuilder sb = new StringBuilder();
String line = null;
int i=0;
while ((line = reader.readLine()) != null) {
sb.append(line);
items.add(new listviewitem()
{{
imgview=R.drawable.ic_launcher;
String my_string_1 = new String(sb.toString().getBytes("ISO-8859-1"),"UTF-8");
txttitel=my_string_1;
}});
}
is.close();
اینم کد php
$al=mysqli_query($con,"SELECT post_title FROM wp_cityposts where post_type='post'");
$response = array();
while($r = mysql_fetch_assoc($al))
{
$response[]=$r;
}
// }
//echo json_encode($response[]);
print($response);
من یک شمارنده که قرار دادم حلقه فایل php 1056 بار اجرا میشه ولی چیزی داخل برنامه ارسال نمی گردد!
بنده یک برنامه ایجاد کردم که داده هاشو از اینترنت باید دریافت کنه (برنامه برای نمایش اطلاعات سایت) برنامه زمانیکه یک رشته ساده را از اینترنت می فرستم درست عمل میکنه و نمایش میده ولی نمیدونم چرا زمانیکه آرایه ای حاوی رشته ها را می خواهد بفرستد مقدار خالی را نمایش می دهد !!
اینم کد دریافت اطلاعات از سرور :
try {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("action", "نرم افزار"));
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params);
entity.setContentEncoding(HTTP.UTF_8);
entity.setContentType("application/json");
httpPost.setEntity(entity);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
final StringBuilder sb = new StringBuilder();
String line = null;
int i=0;
while ((line = reader.readLine()) != null) {
sb.append(line);
items.add(new listviewitem()
{{
imgview=R.drawable.ic_launcher;
String my_string_1 = new String(sb.toString().getBytes("ISO-8859-1"),"UTF-8");
txttitel=my_string_1;
}});
}
is.close();
اینم کد php
$al=mysqli_query($con,"SELECT post_title FROM wp_cityposts where post_type='post'");
$response = array();
while($r = mysql_fetch_assoc($al))
{
$response[]=$r;
}
// }
//echo json_encode($response[]);
print($response);
من یک شمارنده که قرار دادم حلقه فایل php 1056 بار اجرا میشه ولی چیزی داخل برنامه ارسال نمی گردد!