<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
*/
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);
+++ /dev/null
-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);
- }
-
-}