In this section, we will see the android application. In your folder, open the file of the project about Android Studio.
We have here the XML code generated in the code of the interface:
FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> tools:ignore="MergeRootFrame"> <WebView android:id="@+id/activity_main_webview" android:layout_width="match_parent" android:layout_height="match_parent" /> </FrameLayout>
When we create the project, some class are generated automatically, as we will see in the following lines:
import android.webkit.WebView;
public class MonitoringTemperatureHumidity extends ActionBarActivity { private WebView mWebView;
In this part of the code from the android application, we request for the value:
mWebView.loadUrl("http://192.168.1.110/temperature"); mWebView.loadUrl("http://192.168.1.110/humidity"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_monitoring_temperature_humidity);
We define the objects that will be included in the main activity, in this case it is the mWebView
control, it is defined in the main activity of the application:
mWebView = (WebView) findViewById(R.id.activity_main_webview); mWebView.loadUrl("http://192.168.1.110/humidity"); }
In order to give permission to the application to execute networking permissions, it's necessary that we add the following line in the Android Manifest file:
<uses-permission android:name="android.permission.INTERNET"/>
When the application is debugged and installed on the device, we will see the following results on our screen, displaying the value of the temperature
:
The value of the humidity
:
52.14.174.133