‫We tried to get the first question.
‫Everything is working fine.
‫The layout, the activity, the architecture, but nothing happened.
‫We need to specify the security rules.
‫So the problem here is a security issue.
‫I'll create a new file in the XML.
‫So open XML and create new XML resource file.
‫And I'll name it as network underscore security underscore config.
‫Go split mode and I'll change this preference screen to network dash security dash config.
‫Here I remove this namespace.
‫And this file is used to define network security configurations for your app.
‫It's important to use this configuration file to enhance the security and protect sensitive data during
‫network communication.
‫For example, you can require that all network traffic should use Https, SSL, TLS to encrypt data
‫in transit, preventing man in the middle attacks and data leaks.
‫The default behavior of Android is to disallow clear text unencrypted network traffic for security reasons.
‫However, in some cases your app might need to connect to non Https servers, and in such scenarios
‫you can explicitly allow clear text traffic using this file.
‫This is done by setting clear text traffic permitted to true.
‫So I'll start by using base config.
‫And by the way, I'll show you another way to do this.
‫Clear text traffic permitted equals to true.
‫And inside this base traffic base config I'll use trust anchors and certificates.
‫You can specify the trust anchors or certificates that your app trusts.
‫This helps in ensuring that your app communicates only with trusted servers and validates the authenticity
‫of the server's certificate.
‫This is crucial for protecting against man in the middle attacks.
‫Then here in the application I need to specify network security config and I'll use this example and
‫network security configuration file that we created now.
‫So here I'm referencing this file.
‫And I'm telling Android that the network security config is specified in this file.
‫Or if you don't need to create this file you can specify users clear traffic or text traffic to.
‫True.
‫It's very simple.
‫Okay guys.
‫So you can use either this method or this method network security config.
‫Let's run our application.
‫And again we don't have any response.
‫And to solve this error we didn't get anything.
‫Now we are going to change the address the base URL.
‫If we go back to the localhost and the API we can see that 127.00.0.1 is used here.
‫I can't use 127.0.0.1 because it refers to the host, but in emulators I need to use this IP address
‫10.00 .2.2.
‫This is a special IP address that is used as a loopback address to access the host machine's localhost
‫from within an Android emulator.
‫It's a convenient way to access web services or resources running on the host machine while testing
‫your Android application on an emulator.
‫When you use 10.0 .2.2 in your Android applications, code as the host for network requests, or when
‫configuring your app to connect to a server.
‫As this, the emulator redirects the traffic to the host machine's loopback interface.
‫This allows the emulator to communicate with services running on the host.
‫Now let's run our application and here we go.
‫This is question number one.
‫What is the result of five times six, 30, 35, 25 and 40?
‫Back to the response we can see.
‫The first question is this.
‫And congratulations guys.
‫We succeeded in getting the first question.
‫Now let's move to get all the questions.