private void processSubscriptionRequest(Bundle data) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
long pubId = preferences.getLong(MobileClient.PUBLISHER_ID, 0);
// The id must be parsed, as it is in fact a String
long subId = Long.parseLong(data.getString(SUBSCRIBER_ID));
String subUsername = data.getString(SUBSCRIBER_USERNAME);
int notificationId = 1;
// Pending Intent for the Reject action
PendingIntent rejectPendingIntent = createPendingIntentForActions(
NotificationProcessorReceiver.ACTION_REJECT, pubId, subId, subUsername, notificationId);
// Pending Intent for the Accept action
PendingIntent acceptPendingIntent = createPendingIntentForActions(
NotificationProcessorReceiver.ACTION_ACCEPT, pubId, subId, subUsername, notificationId);
Notification.Builder notificationBuilder = new Notification.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("MAGPIE Notification")
.setContentText("Subscription request from " + subUsername)
.addAction(R.drawable.abc_ic_clear_material, "Reject", rejectPendingIntent)
.addAction(R.drawable.ic_done_black_24dp, "Accept", acceptPendingIntent);
Notification notification = notificationBuilder.build();
notification.flags |= Notification.FLAG_NO_CLEAR;
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(notificationId, notification);
}
GcmMessageHandler.java 文件源码
java
阅读 30
收藏 0
点赞 0
评论 0
项目:Android_watch_magpie
作者:
评论列表
文章目录