Advertisement
irobust

Android Network Policy

Sep 16th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. 1. Network Security Config
  2. <network-security-config>
  3. <domain-config cleartextTrafficPermitted="true">
  4. <domain includeSubdomains="true">10.0.2.2</domain>
  5. </domain-config>
  6. </network-security-config>
  7.  
  8. 2. Android Menifest
  9. <uses-permission android:name="android.permission.INTERNET" />
  10. <application android:networkSecurityConfig="@xml/network_security_config"
  11.  
  12. 3. Call Service
  13. Call<List<Product>> products = service.getAll();
  14.  
  15. products.enqueue(new Callback<List<Product>>() {
  16. @Override
  17. public void onResponse(Call<List<Product>> call, Response<List<Product>> response) {
  18. Log.d("DEBUG", response.body().toString());
  19. }
  20.  
  21. @Override
  22. public void onFailure(Call<List<Product>> call, Throwable t) {
  23. Log.d("DEBUG", "Fail to connect api");
  24. }
  25. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement