Don't call pollServer from a BroadcastRecevier
[fonbot.git] / src / ro / ieval / fonbot / Utils.java
index 1262513a3a477a2358c54eb603e57647b6cec9d3..f06c43acc6813e0003796a472080e37d2bc7251b 100644 (file)
@@ -411,7 +411,7 @@ public final class Utils {
        }
 
        /**
-        * Poll the server for pending commands.
+        * Poll the server for pending commands. This function must not be called from BroadcastReceivers
         *
         * @param context Context instance
         */
@@ -419,6 +419,16 @@ public final class Utils {
                new HttpCallExecutableRunnable("/get", null, context, new PollResultCallback(context), false).execute();
        }
 
+       /**
+        * Poll the server for pending commands from {@link FonBotMainService}. This function should be used from BroadcastReceviers instead of {@link #pollServer}
+        *
+        * @param context Context instance
+        */
+       public static void safePollServer(final Context context){
+               final Intent intent=new Intent(context, FonBotMainService.class);
+               intent.setAction(FonBotMainService.ACTION_TRIGGER_POLL);
+               context.startService(intent);
+       }
        /**
         * Executes a given command
         *
This page took 0.00998 seconds and 4 git commands to generate.