Back to project page LearningAndroid2edYamba2.
The source code is released under:
Apache License
If you think the Android project LearningAndroid2edYamba2 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.marakana.android.yamba; /*w w w. j a v a2 s. co m*/ import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; public class NotificationReceiver extends BroadcastReceiver { public static final int NOTIFICATION_ID = 42; @Override public void onReceive(Context context, Intent intent) { NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); int count = intent.getIntExtra("count", 0); PendingIntent operation = PendingIntent.getActivity(context, -1, new Intent(context, MainActivity.class), PendingIntent.FLAG_ONE_SHOT); Notification notification = new Notification.Builder(context) .setContentTitle("New tweets!") .setContentText("You've got " + count + " new tweets") .setSmallIcon(android.R.drawable.sym_action_email) .setContentIntent(operation) .setAutoCancel(true) .build(); // clk: getNotification() was deprecated in API level 16 notificationManager.notify(NOTIFICATION_ID, notification); } }