session-android/src/org/thoughtcrime/securesms/gcm/GcmIntentService.java

46 lines
1.5 KiB
Java
Raw Normal View History

2013-03-26 04:26:03 +00:00
package org.thoughtcrime.securesms.gcm;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.google.android.gcm.GCMBaseIntentService;
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
import org.thoughtcrime.securesms.service.RegistrationService;
public class GcmIntentService extends GCMBaseIntentService {
public static final String GCM_SENDER_ID = "312334754206";
@Override
protected void onRegistered(Context context, String registrationId) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
if (!preferences.getBoolean(ApplicationPreferencesActivity.REGISTERED_GCM_PREF, false)) {
Intent intent = new Intent(RegistrationService.GCM_REGISTRATION_EVENT);
intent.putExtra(RegistrationService.GCM_REGISTRATION_ID, registrationId);
sendBroadcast(intent);
} else {
//
// // Talk to the server directly.
//
}
}
@Override
protected void onMessage(Context context, Intent intent) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
protected void onError(Context context, String s) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
protected void onUnregistered(Context context, String s) {
//To change body of implemented methods use File | Settings | File Templates.
}
}