Android - application isn't working on real device, on virtual device is working  (Rest API over http)

Android - application isn't working on real device, on virtual device is working (Rest API over http)

Good day,

using the development instructions for android, I launched the RestAPI application with the Volley library in the Android studio.

The application accesses the Rest API website under the local IP address via http like http://192.168.5.22, I don't need https, it's just a development version yet.

I test it via AVD on a virtual machine with API 24 - Nougat - Android 7.0. Everything works there. When I run it on a real phone that has android 9 and another with android 10, it doesn't work - I can't get to the data.

If I use an older phone with android 4.4 kitkat, the application works - I get a data listing via rest api.

I don't know what to do with it, I thought there was a permission issue, but I have it set up correctly in AndroidManifest.xml:

< uses-permission android:name="android.permission.INTERNET" / >
< uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" / >

Please help, I've been stuck for a few days, I went for it even though I thought I had to deal with a newer android called Runtime permissions, but it looks like the wrong way. Apparently, an android does not have to apply for internet rights - every android application should have it automatically when it is defined in AndroidManifest.xml.

Thanks for the help

REPLY


Hi,

I solved the whole problem with internet access very simply in the end, but the problem was to find a solution.

I added one line to the android manifest:
android:usesCleartextTraffic="true"

And the application works.

What I read, this must be set if the target web server has only the http protocol and not secure https .... It has been introduced since Android 9 ...

Související obsah

android

programovani

android-studio

api

restapi

java

Komentáře

Vaše reakce na Android - aplikace nefunguje na skutečném telefonu, ve virtuálním funguje (Rest API přes http)

Reference

Podívejte se na naše reference

Prohlédnout

Aplikace

Podívejte se na naše aplikace

Prohlédnout

Co umíme?

Podívejte se co umíme

Prohlédnout

Co umíme?

Vytváříme sofistikované aplikace pro náročné

Od webových aplikací přes android až po převodové můstky či složité informační systémy.

Podívejte se k nám

Máte ještě čas? Podívejte se na další rubriky

Tento web používá soubory cookie. Dalším procházením tohoto webu vyjadřujete souhlas s jejich používáním.. Více informací zde.