There is a server in php, which says: Hello World! How to create an android application so that it accesses the server and displays it?
- @Seth, According to the rules of the forum, questions should not be limited to the decision or the completion of student assignments. Please clarify what you have done yourself and what did not work out. - Vladyslav Matviienko
|
2 answers
You need to send a request to the server, get an answer (the very best line) and display it in a convenient way (for example, in TextView). Make a get request is not difficult, there are even ready-made examples .
- To send HTTP GET request follow the steps. 1. Create an object of HttpClient HttpClient client = new DefaultHttpClient (); 2. Create an object of HttpGet HttpGet request = new HttpGet (" example.com" ); 3. Finally make HTTP request HttpResponse response; try {response = client.execute (request); Log.d ("Response of GET request", response.toString ()); } catch (ClientProtocolException e) {// TODO Auto-generated catch block e.printStackTrace (); } catch (IOException e) {// TODO Auto-generated catch block e.printStackTrace (); } I do not understand this - Seth
- What should be done? Is it in Android Studio? If so, in which place? - Seth
- I thought that you could create a simple application (not even for an android). Open startandroid site or similar and start exploring the database. But where exactly to plug in the code and how to plug in the android studio will be a very long time to explain. - KoVadim
- The fact is that simple, send a request to the server and bring hello world! Or what will be written there - Seth
- 2Then formulate the question correctly, at the end it should be at least like this: "I need detailed instructions, with pictures and preferably a video, as well as a finished project." But just like this is not very fond of. - KoVadim
|
Maybe we should start with the Kivy (Python) framework? Good near-zero entry threshold + multiplatform (convenient to debug and the customer base is not limited to the phone / tablet).
Here is an example from the documentation on getting data over HTTP: https://kivy.org/docs/api-kivy.network.urlrequest.html
|