I'm trying to connect to database server via android.
My question is can I somehow use localhost url like this:
private const val ROOT_URL = "http://localhost/android/v1/"
Instead of providing my computer's IP address? This is my school project and I have some concerns when I present it something will not work because of the different IP.
I've already tested it like this:
private const val ROOT_URL = "http://IP/android/v1/"
And everything works. So my only question is can I replace the IP address with something static that doesn't need to be changed when I connect to another Wi-Fi network
There is errorlog when I use 'http://localhost/android/v1/' or 'https://localhost/android/v1/':
E/Volley: [2503] NetworkDispatcher.processRequest: Unhandled exception java.lang.RuntimeException: Bad URL localhost/android/v1/userLogin.php
java.lang.RuntimeException: Bad URL localhost/android/v1/userLogin.php
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:175)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:131)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)
Caused by: java.net.MalformedURLException: no protocol: localhost/android/v1/userLogin.php
at java.net.URL.<init>(URL.java:601)
at java.net.URL.<init>(URL.java:498)
at java.net.URL.<init>(URL.java:447)
at com.android.volley.toolbox.HurlStack.executeRequest(HurlStack.java:87)
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:123)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:131)?
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111)?
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)?
question from:
https://stackoverflow.com/questions/65931405/e-volley-2458-networkdispatcher-processrequest-unhandled-exception-java-lang 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…