I am working on esp8266 and wanted to make application on Android studio. My Problem is the when i press push button on the application ,the url open which i dont want do it.Because if the url open there is no make sense to see the url.
Other people also answered it (Execute URL without opening browser in Android ,Starting an ACTION_VIEW activity to open the browser, how do I return to my app?) but,it not working for me. Kindly Help me !
Android studio java code
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void clicking(View view) throws IOException {
// Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://192.168.4.1/LEDON?"));
// startActivity(intent);
URL myURL = new URL("http://192.168.4.1/LEDON?");
URLConnection myURLConnection = myURL.openConnection();
myURLConnection.getContent(); // -> calls getHeaderField("content-lengt
// URL myURL = new URL("http://192.168.4.1/LEDON?");
// URLConnection myURLConnection = myURL.openConnection();
// try (InputStream is = myURLConnection.getInputStream()) {}
}
}