@Override public void processPacket(Packet packet) { if (!(packet instanceof Presence)) return; Presence p = (Presence) packet; if (p.getType() != Presence.Type.subscribe) return; String from = p.getFrom(); Notification notification = new Notification( android.R.drawable.stat_notify_more, mService.getString(R.string.AcceptContactRequest, from), System.currentTimeMillis()); notification.flags = Notification.FLAG_AUTO_CANCEL; Intent intent = new Intent(mService, Subscription.class); intent.setData(Contact.makeXmppUri(from)); notification.setLatestEventInfo( mService, from, mService.getString(R.string.AcceptContactRequestFrom, from), PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT)); int id = p.hashCode(); mService.sendNotification(id, notification); }