0

i´m from Germany sorry for my bad english. I am coding an android to control a Java project whit users ... The problem is my App doesn´t want to connect to the Website. Here the Code:

 btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try{
            String url = "http://192.168.178.56/app/AddUser.php?user="
+userb.getText().toString();

                BufferedReader f = new BufferedReader(new
InputStreamReader(new URL(url).openStream()));
                AlertDialog.Builder ff = new AlertDialog.Builder(context);
                ff.setMessage(f.readLine());
                ff.show();
                f.close();
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    });
Furkan KESKIN
  • 168
  • 3
  • 16
Tim
  • 13
  • 1
  • 5

1 Answers1

0

Try this:

       URL url = new URL("http://192.168.178.56/app/AddUser.php?user="
+userb.getText().toString());
       HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
       try {
         InputStream in = new BufferedInputStream(urlConnection.getInputStream());
         readStream(in);
       } finally {
         urlConnection.disconnect();
       }
T.S
  • 911
  • 8
  • 24