我的应用正在接收如下所示的自定义网址:myapp:// login / token12345。
我在我的主要活动的onCreate(即getIntent()。getData())中处理它,解析出令牌,然后使用Volley和这样的https://staging.redacted.com/a?confirm=token12345这样的URL发出API请求
然而,我得到一个奇怪的MalformedURLException:
NetworkDispatcher.run: Unhandled exception java.lang.RuntimeException: Bad URL https://staging.redacted.com/a?confirm=token12345
java.lang.RuntimeException: Bad URL https://staging.redacted.com/a?confirm=token12345
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:151)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:114)
Caused by: java.net.MalformedURLException: Unknown protocol: myapp
at java.net.URL.<init>(URL.java:182)
at java.net.URL.<init>(URL.java:137)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.processResponseHeaders(HttpURLConnectionImpl.java:451)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:300)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:503)
at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:136)
at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:110)
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:97) at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:114)
它似乎使用了有效的网址,但它表示该方案无效(myapp://)。它就像我收到的自定义网址以某种方式进入我后续的截击请求。有人知道这里发生了什么吗?
同样值得注意的是 - 当我调试应用程序并在发送截击请求之前暂停时,神奇的凌空请求就可以了。