Android Open Source - droidBBpush Push Notifier






From Project

Back to project page droidBBpush.

License

The source code is released under:

This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...

If you think the Android project droidBBpush 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.arg3.examples.droidbb;
/*from   w w w  .  j  a v a  2s.  c o m*/
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;

import com.arg3.examples.droidbb.annotations.ForApplication;

import javax.inject.Inject;


/**
 * Created by c0der78 on 2014-09-14.
 */
public class PushNotifier {
    private static final int NOTIFICATION_ID = 1;
    NotificationManager notificationManager;
    Context context;

    @Inject
    PushNotifier(@ForApplication Context context) {

        this.context = context;

        notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    }

    // Put the message into a notification and post it.
    // This is just one simple example of what you might choose to do with
    // a GCM message.
    public void postMessage(Bundle extras) {

        PendingIntent intent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);

        String message = extras.getString("message");

        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(context)
                        .setSmallIcon(R.drawable.ic_launcher)
                        .setContentTitle("Notification")
                        .setAutoCancel(true)
                        .setContentIntent(intent)
                        .setStyle(new NotificationCompat.BigTextStyle()
                                .bigText(message))
                        .setContentText(message);

        notificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    }

    public void postError(Bundle extras) {
        //TODO: handle error
    }

    public void postDeleted(Bundle extras) {
        //TODO: handle deleted
    }
}




Java Source Code List

com.arg3.droid.bbpush.ApplicationTest.java
com.arg3.examples.droidbb.MainActivity.java
com.arg3.examples.droidbb.MainApplication.java
com.arg3.examples.droidbb.MainModule.java
com.arg3.examples.droidbb.PushNotifier.java
com.arg3.examples.droidbb.PushRegistrar.java
com.arg3.examples.droidbb.PushService.java
com.arg3.examples.droidbb.annotations.ForApplication.java
com.arg3.examples.droidbb.gcm.GCMBroadcastReceiver.java
com.arg3.examples.droidbb.gcm.GCMBroadcastReceiver.java
com.arg3.examples.droidbb.gcm.GCMHandler.java
com.arg3.examples.droidbb.gcm.GCMHandler.java
com.arg3.examples.droidbb.gcm.GCMIntentService.java
com.arg3.examples.droidbb.gcm.GCMIntentService.java
com.arg3.examples.push.AndroidPushService.java
com.arg3.examples.push.ApplicationListener.java
com.arg3.examples.push.BaseServlet.java
com.arg3.examples.push.BlackberryPushService.java
com.arg3.examples.push.MainModule.java
com.arg3.examples.push.PushServlet.java
com.arg3.examples.push.SendServlet.java
com.arg3.examples.push.ViewServlet.java
com.arg3.examples.push.api.BaseAPIServlet.java
com.arg3.examples.push.api.RegisterDeviceServlet.java
com.arg3.examples.push.dao.DeviceDAO.java
com.arg3.examples.push.enums.DeviceType.java
com.arg3.examples.push.model.Device.java