Android Open Source - appservices-android-push-example Util






From Project

Back to project page appservices-android-push-example.

License

The source code is released under:

Apache License

If you think the Android project appservices-android-push-example 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

package com.ganyo.pushtest;
// w ww. ja va2  s .co m
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.google.android.gcm.GCMRegistrar;

public final class Util {

  static final String TAG = "com.ganyo.pushtest";
  static final String DISPLAY_MESSAGE_ACTION = "com.ganyo.pushtest.DISPLAY_MESSAGE";
  static final String EXTRA_MESSAGE = "message";

  static void displayMessage(Context context, String message) {
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtra(EXTRA_MESSAGE, message);
    context.sendBroadcast(intent);
  }

  static void registerPush(Context context) {

    final String regId = GCMRegistrar.getRegistrationId(context);

    if ("".equals(regId)) {
      GCMRegistrar.register(context, Settings.GCM_SENDER_ID);
    } else {
      if (GCMRegistrar.isRegisteredOnServer(context)) {
        Log.i(TAG, "Already registered with GCM");
      } else {
        AppServices.register(context, regId);
      }
    }
  }
}




Java Source Code List

com.ganyo.pushtest.AlertDialogManager.java
com.ganyo.pushtest.AppServices.java
com.ganyo.pushtest.GCMIntentService.java
com.ganyo.pushtest.MainActivity.java
com.ganyo.pushtest.Settings.java
com.ganyo.pushtest.Util.java
com.ganyo.pushtest.WakeLocker.java