Copyright ? 2014 Microsoft Mobile Oy. All rights reserved.
Microsoft is a registered trademark of Microsoft Corporation. Nokia and HERE are
trademarks and/or registered trademarks of Nokia Corporati...
If you think the Android project capture-the-flag listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright (c) 2014 Microsoft Mobile. All rights reserved.
* See the license text file provided with this project for more information.
*//*fromwww.java2s.com*/package com.nokia.example.capturetheflag.notifications.nokia;
import com.nokia.example.capturetheflag.notifications.NotificationsUtils;
import com.nokia.push.PushBaseIntentService;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
/**
* Intent service responsible for handling Nokia Notifications push messages.
*
* @see {@link PushBaseIntentService}.
*/publicclass NokiaNotificationsIntentService extends PushBaseIntentService {
publicstaticfinal String SENDER_ID = "capture-the-flag"; // Sender ID for Nokia Notifications
privatestaticfinal String TAG = "CtF/PushIntentService";
/**
* Constructor.
*/public NokiaNotificationsIntentService() {
}
@Override
protected String[] getSenderIds(Context context) {
returnnew String[]{SENDER_ID};
}
@Override
protectedvoid onRegistered(Context context, String registrationId) {
Log.i(TAG, "Device registered with ID \"" + registrationId + "\"");
}
@Override
protectedvoid onUnregistered(Context context, String registrationId) {
Log.i(TAG, "Device unregistered");
}
@Override
protectedvoid onMessage(Context context, Intent intent) {
Log.i(TAG, "Received message. Extras: " + intent.getExtras());
Bundle extras = intent.getExtras();
NotificationsUtils.broadcastGameMessage(extras.getString("payload"), this);
NokiaNotificationsBroadcastReceiver.completeWakefulIntent(intent);
}
@Override
protectedvoid onDeletedMessages(Context context, int total) {
Log.i(TAG, "Received deleted messages notification");
}
@Override
publicvoid onError(Context context, String errorId) {
Log.i(TAG, "Received error: " + errorId);
// TODO: Show error message
}
@Override
protectedboolean onRecoverableError(Context context, String errorId) {
Log.e(TAG, "Received recoverable error: " + errorId);
return super.onRecoverableError(context, errorId);
}
}