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






From Project

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

License

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;
import com.google.android.gcm.GCMBaseIntentService;
 
public class GCMIntentService extends GCMBaseIntentService {
 
    private static final String TAG = "GCMIntentService";
 
    public GCMIntentService() {
        super(SENDER_ID);
    }
 
    /**
     * Method called on device registered
     **/
    @Override
    protected void onRegistered(Context context, String registrationId) {
      try{
      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);
            editor.commit();
            
            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 */
    @Override
    protected void onMessage(Context context, Intent intent) {
        Log.i(TAG, "Received message");
        AppUtility appUtility = new AppUtility(context);
        appUtility.notiFyDevice(
            intent.getExtras().getString("Notification"),
            intent.getExtras().getString("sender"),
            intent.getExtras().getString("Comment"),
            intent.getExtras().getString("Photo")
            );
    }
 ;

    /**
     * Method called on Error
     * */
    @Override
    public void onError(Context context, String errorId) {
        Log.i(TAG, "Received error: " + errorId);
        displayMessage(context, "GCM Error"+ errorId);
    }
 
    @Override
    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);
    }
 
 @Override
  protected void onUnregistered(Context arg0, String arg1) {
    // TODO Auto-generated method stub
    
  }
 
}




Java Source Code List

com.appsng.adapters.CommentAdapter.java
com.appsng.adapters.ImagePagerAdapter.java
com.appsng.adapters.NotificationAdapter.java
com.appsng.adapters.PhotoGridAdapter.java
com.appsng.adapters.PhotoItemAdapter.java
com.appsng.adapters.PortfolioAdapter.java
com.appsng.connectors.AppUtility.java
com.appsng.connectors.CustomHttpClient2.java
com.appsng.connectors.CustomHttpClient.java
com.appsng.connectors.HttpFileUpload.java
com.appsng.connectors.LocalDataBase.java
com.appsng.models.Comment.java
com.appsng.models.Notification.java
com.appsng.models.PhotoList.java
com.appsng.models.Photo.java
com.appsng.models.Portfolio.java
com.appsng.reusables.Base64.java
com.appsng.reusables.CropOptionAdapter.java
com.appsng.reusables.CropOption.java
com.appsng.reusables.ImageHelper.java
com.appsng.reusables.TransparentDialog.java
com.appsng.reusables.Utilities.java
com.appsng.reusables.WakeLocker.java
com.appsng.reusables.ZoomImage.java
com.ekoconnect.afriphoto.fragments.BaseFragment.java
com.ekoconnect.afriphoto.fragments.Comments.java
com.ekoconnect.afriphoto.fragments.FragmentImageView.java
com.ekoconnect.afriphoto.fragments.Home.java
com.ekoconnect.afriphoto.fragments.Index.java
com.ekoconnect.afriphoto.fragments.Notifications.java
com.ekoconnect.afriphoto.fragments.Register.java
com.ekoconnect.afriphotos.ActivityFragment.java
com.ekoconnect.afriphotos.AwesomeActivity.java
com.ekoconnect.afriphotos.CameraActivity.java
com.ekoconnect.afriphotos.CopyOfMainActivity.java
com.ekoconnect.afriphotos.GCMIntentService.java
com.ekoconnect.afriphotos.GCM.java
com.ekoconnect.afriphotos.HomeActivity.java
com.ekoconnect.afriphotos.ImageViewActivity.java
com.ekoconnect.afriphotos.ImageViewPager.java
com.ekoconnect.afriphotos.MainActivity.java
com.ekoconnect.afriphotos.MyPhotos.java
com.ekoconnect.afriphotos.NotificationActivity.java
com.ekoconnect.afriphotos.Portfolio.java
com.ekoconnect.afriphotos.RefreshListView.java
com.ekoconnect.afriphotos.SplashScreen.java
com.ekokonnect.aada.MainActivity.java