Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
receiveNotification
public class NotificationActionReceiver extends WakefulBroadcastReceiver {
@Override public void onReceive(Context context, Intent intent) {
String action = intent.getStringExtra("action");
int id = intent.getIntExtra("id");
switch (action) {
case "Approve":
// Start service to approve transaction and hold wake lock
Intent approveIntent = new Intent("com.example.app.ApproveService");
intent.putExtra("id", id);
startWakefulService(context, approveIntent);
break;
case "Deny":
// Clear existing notification
NotificationManager nm = context.getSystemService(NOTIFICATION_MANAGER);
nm.cancel(id);
break;
default:
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.