Android Open Source - african-art-talent-discovery G C M Intent Service

From Project

Back to project page african-art-talent-discovery.


The source code is released under:

GNU General Public License

If you think the Android project african-art-talent-discovery 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.ekoconnect.afriphotos;
/*from   w w  w  . j av  a  2s  . c om*/

import static com.ekoconnect.afriphotos.GCM.SENDER_ID;
import static com.ekoconnect.afriphotos.GCM.displayMessage;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;

import com.appsng.connectors.AppUtility;
import com.appsng.reusables.Utilities;
public class GCMIntentService extends GCMBaseIntentService {
    private static final String TAG = "GCMIntentService";
    public GCMIntentService() {
     * Method called on device registered
    protected void onRegistered(Context context, String registrationId) {
      Log.i(TAG, "Device registered: regId = " + registrationId);
        GCM.displayMessage(context, "Your device registred with GCM");
        Log.d("DEVICEID", GCM.deviceid);
        //GCM.register(context, GCM.deviceid, registrationId); 
          if(registrationId.equals("")) {
            Log.i(TAG, "Device ID not registered");
          }else {
            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
            SharedPreferences.Editor editor = preferences.edit();
            editor.putString("regid", registrationId);
            AppUtility appUtility = new AppUtility(context);
            appUtility.registerUnregisterDevice(GCM.deviceid, registrationId, "register_push");
      }catch(Exception d){
        Utilities.log("ERROR REGISTERING",d.toString());

    /** Method called on Receiving a new message */
    protected void onMessage(Context context, Intent intent) {
        Log.i(TAG, "Received message");
        AppUtility appUtility = new AppUtility(context);

     * Method called on Error
     * */
    public void onError(Context context, String errorId) {
        Log.i(TAG, "Received error: " + errorId);
        displayMessage(context, "GCM Error"+ errorId);
    protected boolean onRecoverableError(Context context, String errorId) {
        Log.i(TAG, "Received recoverable error: " + errorId);
        displayMessage(context, "Received recoverable error:" +errorId);
        return super.onRecoverableError(context, errorId);
  protected void onUnregistered(Context arg0, String arg1) {
    // TODO Auto-generated method stub

Java Source Code List