Make custom server work when polling
[fonbot.git] / src / ro / ieval / fonbot / PollServerAsyncTask.java
index 7e95303090df4f2a6cfc5d58006d211cd0d222c9..2a4a21d60fe73661bdc9b652f3647eb4a7d791bd 100644 (file)
@@ -15,6 +15,7 @@ import org.json.JSONException;
 import org.json.JSONObject;
 
 import ro.ieval.fonbot.Address.Protocol;
+import android.content.Context;
 import android.os.AsyncTask;
 import android.util.Log;
 
@@ -76,12 +77,24 @@ public final class PollServerAsyncTask extends AsyncTask<Void, Void, List<PollSe
                }
        }
 
+       /** Context instance */
+       private final Context context;
+
+       /**
+        * Constructs a PollServerAsyncTask.
+        *
+        * @param context Context instance
+        */
+       public PollServerAsyncTask(final Context context) {
+               this.context=context;
+       }
+
        @Override
        protected List<Command> doInBackground(final @Nullable Void... params) {
                Log.d(getClass().getName(), "Polling server");
                final List<Command> commands=new ArrayList<Command>(10);
                try {
-                       final URL url=new URL("http://ieval.ro:7777/get");
+                       final URL url=Utils.getServerURL(toNonNull(context),"/get");
                        final HttpURLConnection conn=(HttpURLConnection) url.openConnection();
                        conn.setRequestProperty("X-ID", FonBotApplication.instance.regID);
                        conn.connect();
This page took 0.00956 seconds and 4 git commands to generate.