السلام عليكم
حملت Ubuntu server وعندما اكتب الاي بي تظهر رسالة في الصفحة It Works
وأريد قراءتها عن طريق برنامج في الاندرويد
كتبت أكواد عديدة ولم تفلح محاولاتي
public class MainActivity extends Activity {
TextView resulttt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
resulttt = (TextView)findViewById(R.id.textView);
String result = null;
InputStream is = null;
StringBuilder sb=null;
String result1 = null;
//http post
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://");
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
Log.e("log_tag", "Error in http connection"+e.toString());
Toast.makeText(this, "1", Toast.LENGTH_LONG).show();
}
//convert response to string
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
sb = new StringBuilder();
sb.append(reader.readLine() + "\n");
String line="0";
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result1=sb.toString();
resulttt.setText(result1);
}catch(Exception e){
Log.e("log_tag", "Error converting result "+e.toString());
Toast.makeText(this, "2", Toast.LENGTH_LONG).show();
}