Skip to content

Instantly share code, notes, and snippets.

@a1yama
Last active January 20, 2016 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a1yama/2e645e31b9803c66f962 to your computer and use it in GitHub Desktop.
Save a1yama/2e645e31b9803c66f962 to your computer and use it in GitHub Desktop.
import android.app.IntentService;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.google.android.gms.gcm.GoogleCloudMessaging;
public class GcmIntentService extends IntentService {
private final String PUSH_MSG_KEY = "message";
private final String PUSH_TITLE_KEY = "title";
private final int NOTIFICATION_ID = 1;
public GcmIntentService() {
super("GcmIntentService");
}
@Override
protected void onHandleIntent(Intent intent) {
try {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
String messageType = gcm.getMessageType(intent);
// TODO notify
}
}
} finally {
// 必ず実行する
GcmBroadcastReceiver.completeWakefulIntent(intent);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment