الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

أريد قراءة النص الذي يظهر لي في الصفحة بعد الاتصال بالسيرفر

بدأه The.Eagle في 9 يونيو 2013 · 1 رد · 399 مشاهدة · في Android
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم 

حملت 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();
	        }

تم تعديل هذه المشاركة بواسطة The.Eagle في 9 يونيو 2013 في 15:53

#2

تم حل المشكلة وشكرا لمن حاول حلها 

 

تغيير هذا السطر 

HttpPost httppost = new HttpPost("http://");

إلى 

 

HttpGet httppost = new HttpGet("http://");

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…