I'm trying to connect any web page by the easiest way. I learnt that i have to use AsyncTask but i want before to see this job.
package com.example.duzbaglanti; import java.io.BufferedInputStream; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import android.os.Bundle; import android.os.StrictMode; import android.app.Activity; import android.util.Log; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.TextView; public class MainActivity extends Activity { String biyazi = "ggg"; TextView tv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); tv = (TextView) findViewById(R.id.textView1); Button benimtus = (Button) findViewById(R.id.button1); benimtus.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { tv.setText(biyazi); } }); HttpURLConnection benimconnection = null; try { URL benimurl = new URL("anypage"); benimconnection = (HttpURLConnection) benimurl.openConnection(); int sonuckodu = benimconnection.getResponseCode(); if(sonuckodu == HttpURLConnection.HTTP_OK) { InputStream benimin = new BufferedInputStream(benimconnection.getInputStream()); biyazi = benimin.toString(); /////// } } catch (Exception e) { Log.d("baglantihatasi","hata oldu",e); } finally { benimconnection.disconnect(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } when i click the button my string changes to 'Java.io.BufferedInputStream@4177b2a8' not my web page's output. what is the wrong?