]> iEval git - fonbot.git/blame - src/ro/ieval/fonbot/GCMIntentService.java
Initial commit
[fonbot.git] / src / ro / ieval / fonbot / GCMIntentService.java
CommitLineData
8dfb76c9
MG
1package ro.ieval.fonbot;
2
3import org.eclipse.jdt.annotation.Nullable;
4
5import android.content.Context;
6import android.content.Intent;
7import android.os.Handler;
8import android.os.Looper;
9
10import com.google.android.gcm.GCMBaseIntentService;
11
12/*
13 * Copyright © 2013 Marius Gavrilescu
14 *
15 * This file is part of FonBot.
16 *
17 * FonBot is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * FonBot is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with FonBot. If not, see <http://www.gnu.org/licenses/>.
29 */
30
31/**
32 * Service that responds to GCM events
33 *
34 * @author Marius Gavrilescu <marius@ieval.ro>
35 */
36public class GCMIntentService extends GCMBaseIntentService {
37 /** Handler instance */
38 private final Handler handler=new Handler(Looper.getMainLooper());
39
40 /**
41 * Constructs a GCMIntentService with the iEval sender id
42 */
43 public GCMIntentService() {
44 super(FonBotApplication.GCM_SENDER_ID);
45 }
46
47 @Override
48 protected void onError(@Nullable final Context context, @Nullable final String errID) {
49 //TODO error handling here
50 }
51
52 @Override
53 protected void onMessage(@Nullable final Context context, @Nullable final Intent intent) {
54 handler.post(new Runnable(){
55 @Override
56 public void run() {
57 new PollServerAsyncTask().execute();
58 }
59 });
60 }
61
62 @Override
63 protected void onRegistered(@Nullable final Context context, @Nullable final String regID) {
64 FonBotApplication.instance.regID=regID;
65 }
66
67 @Override
68 protected void onUnregistered(@Nullable final Context context, @Nullable final String regID) {
69 //do nothing
70 }
71}
This page took 0.031912 seconds and 4 git commands to generate.