Remove LocalBroadcastReceiver
authorMarius Gavrilescu <marius@ieval.ro>
Tue, 26 Mar 2013 10:55:05 +0000 (12:55 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Tue, 26 Mar 2013 10:55:05 +0000 (12:55 +0200)
Since adding FonBotMainService#ACTION_TRIGGER_POLL, LocalBroadcastReceiver became useless, as the alarm can directly poll via the service.

AndroidManifest.xml
src/ro/ieval/fonbot/Heavy.java
src/ro/ieval/fonbot/LocalBroadcastReceiver.java [deleted file]

index f9e15c25156c1fd2bfa5a43a81544b298dca91cf..10305344835332b3e4ac4e6aa5ea37969ca12eb9 100644 (file)
                 <action android:name="android.intent.action.BATTERY_OKAY" />
             </intent-filter>
         </receiver>
-        <receiver
-            android:name=".LocalBroadcastReceiver"
-            android:exported="false" >
-            <intent-filter>
-                <action android:name="ro.ieval.fonbot.LocalBroadcastReceiver.ACTION_POLL_ALARM" />
-            </intent-filter>
-        </receiver>
     </application>
 
 </manifest>
\ No newline at end of file
index 6e91f2f1fbbd61c173ad4105ffb48cd1189b9909..f734437f4c452d8c3ee8dc11f25db109dbfa11f1 100644 (file)
@@ -1519,9 +1519,9 @@ final class Heavy {
         */
        public static void poll(final Context context, final Address replyTo, final long ms){
                final AlarmManager man=(AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
-               final Intent pollAlarm=new Intent(context, LocalBroadcastReceiver.class);
-               pollAlarm.setAction(LocalBroadcastReceiver.ACTION_POLL_ALARM);
-               final PendingIntent intent=PendingIntent.getBroadcast(context, 0, pollAlarm, 0);
+               final Intent pollAlarm=new Intent(context, FonBotMainService.class);
+               pollAlarm.setAction(FonBotMainService.ACTION_TRIGGER_POLL);
+               final PendingIntent intent=PendingIntent.getService(context, 0, pollAlarm, 0);
                if(ms==0){
                        Utils.unregisterOngoing(context, toNonNull(OngoingEvent.POLL));
                        man.cancel(intent);
diff --git a/src/ro/ieval/fonbot/LocalBroadcastReceiver.java b/src/ro/ieval/fonbot/LocalBroadcastReceiver.java
deleted file mode 100644 (file)
index 163310e..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-package ro.ieval.fonbot;
-
-import org.eclipse.jdt.annotation.Nullable;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
-/*
- * Copyright © 2013 Marius Gavrilescu
- * 
- * This file is part of FonBot.
- *
- * FonBot is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * FonBot is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with FonBot.  If not, see <http://www.gnu.org/licenses/>. 
- */
-
-/**
- * BroadcastReceiver that receives appwide local broadcasts.
- *
- * @author Marius Gavrilescu <marius@ieval.ro>
- */
-public final class LocalBroadcastReceiver extends BroadcastReceiver {
-       /**
-        * Broadcast action: the poll alarm has fired, the app should poll the server
-        */
-       public static final String ACTION_POLL_ALARM="ro.ieval.fonbot.SystemEventReceiver.ACTION_POLL_ALARM";
-
-       @Override
-       public void onReceive(final @Nullable Context context, final @Nullable Intent intent) {
-               if(context==null || intent==null)
-                       return;
-
-               final String action=intent.getAction();
-               if(action.equals(LocalBroadcastReceiver.ACTION_POLL_ALARM))
-                       Utils.safePollServer(context);
-       }
-
-}
This page took 0.012758 seconds and 4 git commands to generate.