Android Open Source - scoreflex-android-sdk Scoreflex Gcm Wrapper






From Project

Back to project page scoreflex-android-sdk.

License

The source code is released under:

Apache License

If you think the Android project scoreflex-android-sdk 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.scoreflex.google;
/*w  w w . j  a v a2 s  .co  m*/
import java.io.IOException;

import android.app.Activity;
import android.content.Context;
import android.util.Log;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.gcm.GoogleCloudMessaging;

public class ScoreflexGcmWrapper {
  private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
  private static GoogleCloudMessaging mGcm;
  
  public static boolean isGcmAvailable() { 
    try {
      Class.forName("com.google.android.gms.gcm.GoogleCloudMessaging");
      return true;
    } catch (ClassNotFoundException e) {
      return false;
    }
  }

  public static boolean isGooglePlayServiceAvailable(Activity activity) { 
    try {
      Class.forName("com.google.android.gms.common.GooglePlayServicesUtil");
      int resultCode = GooglePlayServicesUtil
          .isGooglePlayServicesAvailable(activity);
      if (resultCode != ConnectionResult.SUCCESS) {
        if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
          GooglePlayServicesUtil.getErrorDialog(resultCode, activity,
              PLAY_SERVICES_RESOLUTION_REQUEST).show();
        } else {
          Log.d(
              "Scoreflex",
              "this device does not support google play service no push notification will be received");
        }
        return false;
      }    
      return true;
    } catch (ClassNotFoundException e) { 
      return false;
    }
  }
  
  public static String register(Context context, String senderId) throws IOException { 
     if (mGcm == null) {
       mGcm = GoogleCloudMessaging.getInstance(context);
     }
    return mGcm.register(senderId);
  }
  
}




Java Source Code List

com.scoreflex.ConnectivityReceiver.java
com.scoreflex.QueryStringParser.java
com.scoreflex.ScoreflexActivity.java
com.scoreflex.ScoreflexBroadcastReceiver.java
com.scoreflex.ScoreflexGcmClient.java
com.scoreflex.ScoreflexJobQueue.java
com.scoreflex.ScoreflexRequestParamsDecorator.java
com.scoreflex.ScoreflexRequestVault.java
com.scoreflex.ScoreflexRestClient.java
com.scoreflex.ScoreflexUriHelper.java
com.scoreflex.ScoreflexView.java
com.scoreflex.Scoreflex.java
com.scoreflex.SocialCallback.java
com.scoreflex.SocialShareCallback.java
com.scoreflex.facebook.ScoreflexFacebookWrapper.java
com.scoreflex.google.ScoreflexGcmWrapper.java
com.scoreflex.google.ScoreflexGoogleWrapper.java
com.scoreflex.model.JSONParcelable.java