I included following permissions into Manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I am using this code:
try {
java.net.URL url = new URL("http://www.temp372.000webhostapp.com/s.php?t=hello_there");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
} catch (IOException e) {
e.printStackTrace();
t1.setText("problem occured..");
}
Following is the PHP code:
<?php
$fn = "android.txt";
$data = "";
// get whatever they send and store it to the file.
if($_GET["t"])
{
$data = $_GET["t"];
if ($data !== '')
{
$myfile = fopen($fn, "a");
fwrite($myfile, $data . "\n");
fclose($myfile);
}
}
?>
No errors are coming, I am trying running this app into bluestacks and my cellphone (ROG Phone). But results are same, no error or anything as textview is not setting and it just my PHP code is not receiving the information but when I try same URL into my web browser, PHP code runs cool.