public void buloginckic(View view) { //get user name and password EditText UserName=(EditText)findViewById(R.id.EDTUserName); EditText Password=(EditText)findViewById(R.id.EDTpassword); // send user name and password over the http String url="http://sellingportal.alruabye.net/UsersWS.asmx/Login?UserName="+ UserName.getText().toString() +"&Password="+ Password.getText().toString(); // start background task new MyAsyncTaskgetNews().execute(url, "news"); } // get news from server public class MyAsyncTaskgetNews extends AsyncTask<String, String, String> { @Override protected void onPreExecute() { //before works } @Override protected String doInBackground(String... params) { // TODO Auto-generated method stub try { String NewsData; //define the url we have to connect with URL url = new URL(params[0]); //make connect with url and send request HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); //waiting for 7000ms for response urlConnection.setConnectTimeout(7000);//set timeout to 5 seconds try { //getting the response data InputStream in = new BufferedInputStream(urlConnection.getInputStream()); //convert the stream to string NewsData = ConvertInputToStringNoChange(in); //send to display data publishProgress(NewsData); } finally { //end connection urlConnection.disconnect(); } }catch (Exception ex){} return null; } protected void onProgressUpdate(String... progress) { try { //display response data Toast.makeText(getApplicationContext(),progress[0],Toast.LENGTH_LONG).show(); } catch (Exception ex) { } } protected void onPostExecute(String result2){ } } // this method convert any stream to string public static String ConvertInputToStringNoChange(InputStream inputStream) { BufferedReader bureader=new BufferedReader( new InputStreamReader(inputStream)); String line ; String linereultcal=""; try{ while((line=bureader.readLine())!=null) { linereultcal+=line; } inputStream.close(); }catch (Exception ex){} return linereultcal; }