public abstract class AbstractGcmIntentService
extends IntentService
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractGcmIntentService.MessageType |
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String[] |
PUSH_TO_APP_FIELDS |
protected static java.lang.String[] |
PUSH_TO_USER_FIELDS |
Constructor and Description |
---|
AbstractGcmIntentService() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
getAppName(Context context)
Gets app name
|
protected int |
getLargeIcon(Context context)
Gets resource id of large launcher icon.
|
protected AbstractGcmIntentService.MessageType |
getMessageType(JSONObject message) |
protected java.lang.Integer |
getNotificationColor(Context context)
Get ARBG color for notification color
|
protected boolean |
getResouceValueAsBoolean(java.lang.String key)
Gets the boolean value to which the specified key is mapped, or false if resource file contains no mapping for the key.
|
protected int |
getResouceValueAsInteger(java.lang.String key)
Gets the int value to which the specified key is mapped, or 0 if resource file contains no mapping for the key.
|
protected java.lang.String |
getResouceValueAsString(java.lang.String key)
Gets the string value to which the specified key is mapped, or null if resource file contains no mapping for the key.
|
protected int |
getSmallIcon(Context context)
Gets resource id of small launcher icon.
|
protected int |
getSound()
Gets resource id of sound file.
|
protected java.lang.String |
getText(JSONObject json,
java.lang.String text,
java.lang.String fallback) |
protected boolean |
isForeground()
Checks if the application is on foreground.
|
protected void |
onHandleIntent(Intent intent) |
protected abstract boolean |
onHandlePushMessage(Context context,
AbstractGcmIntentService.MessageType messageType,
JSONObject receivedMessage,
boolean isForeground)
Called by IntentService when service receives push notification.
|
protected java.lang.Integer |
parseArgb(java.lang.String argbString)
Convert string value which indicates color into the integer value.
|
protected void |
showNotificationArea(Context context,
JSONObject message,
boolean useSound,
java.lang.String ledColor,
long vibrationMilliseconds,
java.lang.String title,
java.lang.String ticker,
java.lang.String text)
Shows a received message in the notification area.
|
protected JSONObject |
toJson(Bundle bundle)
Converts Bundle to JSONObject.
|
protected static final java.lang.String[] PUSH_TO_APP_FIELDS
protected static final java.lang.String[] PUSH_TO_USER_FIELDS
protected java.lang.String getAppName(Context context)
context
- protected int getLargeIcon(Context context)
context
- protected AbstractGcmIntentService.MessageType getMessageType(JSONObject message)
protected java.lang.Integer getNotificationColor(Context context)
context
- protected boolean getResouceValueAsBoolean(java.lang.String key)
key
- protected int getResouceValueAsInteger(java.lang.String key)
key
- protected java.lang.String getResouceValueAsString(java.lang.String key)
key
- protected int getSmallIcon(Context context)
context
- protected int getSound()
protected java.lang.String getText(JSONObject json, java.lang.String text, java.lang.String fallback)
json
- text
- literal or JSONPathfallback
- protected boolean isForeground()
protected void onHandleIntent(Intent intent)
protected abstract boolean onHandlePushMessage(Context context, AbstractGcmIntentService.MessageType messageType, JSONObject receivedMessage, boolean isForeground)
context
- messageType
- receivedMessage
- isForeground
- protected java.lang.Integer parseArgb(java.lang.String argbString)
argbString
- #AARRGGBBprotected void showNotificationArea(Context context, JSONObject message, boolean useSound, java.lang.String ledColor, long vibrationMilliseconds, java.lang.String title, java.lang.String ticker, java.lang.String text)
context
- message
- useSound
- ledColor
- format is '#AARRGGBB'vibrationMilliseconds
- set 0 if you want to disable vibration.title
- Literal text or JsonPathtext
- Literal text or JsonPathprotected JSONObject toJson(Bundle bundle)
bundle
-