Created
November 5, 2013 17:21
-
-
Save cirocosta/7322664 to your computer and use it in GitHub Desktop.
BroadcastReceiver e Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MeuGcmBroadcastReceiver extends WakefulBroadcastReceiver { | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
// Explicitly specify that GcmIntentService will handle the intent. | |
ComponentName comp = new ComponentName(context.getPackageName(), | |
GcmIntentService.class.getName()); | |
// Start the service, keeping the device awake while it is launching. | |
startWakefulService(context, (intent.setComponent(comp))); | |
setResultCode(Activity.RESULT_OK); | |
} | |
} | |
public class MeuGcmService extends IntentService { | |
public static final int NOTIFICATION_ID = 1; | |
private NotificationManager mNotificationManager; | |
NotificationCompat.Builder builder; | |
public GcmIntentService() { | |
super("GcmIntentService"); | |
} | |
@Override | |
onHandleIntent(Intent intent){ | |
Bundle extras = intent.getExtras(); | |
//processamento como desejar | |
processaMensagem(extras); | |
MeuGcmService.completeWakefulIntent(intent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment