I'm making a simple Android Wear app to control my thermostats, and I'm sending POST requests from Volley to control them. Everything works fine in the Android Wear simulator (the request works), but while the application is loading on my Moto 360, the volleyball request is called, but the time runs out invariably.
Why can my volleyball request not work on my watch, but work with a simulator? Requests for other applications were successful on my watch (for example, the built-in weather application can download weather data in about 3 seconds). And the strangest part: I had an application running (successfully executing volleyball requests) on my watch, and about a day after I installed it on my watch from Android Studio, it suddenly stopped downloading data for no apparent reason.
What I have tried so far:
- I requested permission for the web in
manifest.xml . - I increased the timeout to 30 seconds (see my code below), which didn't change anything.
- I tried to connect my computer and simulator to my telephone connection via Bluetooth (in order to play back the Bluetooth connection that my physical watch has on my phone), and the simulator successfully completed the request (albeit with a two-second delay), excluding the possibility of Bluetooth running too slow.
- I made sure that the API level is low enough for my watch in Marshmallow (my watch and app are both API 23 levels).
- I tried to execute a quick check request on Google before requesting the companyβs servers with the data of my thermostat, and while the Google request returns the HTML code of the site in the simulator, it occasionally appears on my watch (it is initiated thirty seconds after the request) .
- I tried to put some dummy data into the recycler view data that should be loaded, and the dummy data really appeared, which caused the recycler view to fail.
- I removed the application from my watch and reinstalled it, and uninstalled the companion from my phone, reinstalled it and deleted it again, all to no avail.
- A long chat with Google didnβt bring anything meaningful.
Here is my code (from my main adapter):
public void refreshThermostatsRecyclerView(RequestQueue queue) { String url = "https://mobile.skyport.io:9090/login"; // login call to the thermostats server Skyport Log.w("myApp", "Starting /login call to Skyport"); // this gets called on simulator and watch // Request a string response from the provided URL. StringRequest stringRequest = new StringRequest(Request.Method.POST, url, Response.Listener<String>() { @Override public void onResponse(String response) { // Display the response string. Log.w("myApp", "Response is: " + response); // this gets called on the simulator but not the watch try { // there some code to parse the data. } catch (JSONException e) { Log.w("myApp", "catching an error parsing the json."); // never gets called. e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.w("myApp", "Skyport request didn't work! " + error); // this always gets called on the watch, with the error being a timeout error (com.Android.Volley.timeouterror) but never gets called in the simulator } }) { @Override public Map<String, String> getHeaders() throws AuthFailureError { Map<String, String> m = new HashMap<>(); m.put("Referer", "app:/VenstarCloud.swf"); // here I put some more headers return m; } @Override protected Map<String, String> getParams() throws AuthFailureError { Map<String, String> m = new HashMap<>(); m.put("version", "3.0.5"); m.put("email", userEmail); m.put("password", userToken); return m; } }; // Add the request to the RequestQueue. int socketTimeout1 = 30000; // times out 30 seconds after the request starts on the watch RetryPolicy policy1 = new DefaultRetryPolicy(socketTimeout1, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT); stringRequest.setRetryPolicy(policy1); queue.add(stringRequest); }
, which is called from the onCreate() method in my main activity using this code:
RequestQueue queue = Volley.newRequestQueue(this); refreshThermostatsRecyclerView(queue);
If you want to view the logs created by running this in the simulator and on the watch, they are on Google Drive here .
Edit 1:. Rebooting my watch temporarily fixes the problem and allows the watch to make HTTP requests again, but it breaks again when the watch disconnects from Bluetooth, connects to WiFi, disconnects from WiFi, and reconnects to Bluetooth (so it breaks every time I switch through my apartment without a phone, and then come back).
Edit 2:. I switched volleyball requests to all HTTPURLConnection requests in the Async stream, and the same problems arise as volleyball.
tl; dr: My application Volleyball requests work in the simulator, but not on my Android Wear watch anymore (although similar requests for Play-downloaded applications work), how can I get a volley to ask to work again in my application on the watch?