Skip to content

Instantly share code, notes, and snippets.

@SeanPONeil
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeanPONeil/10669730 to your computer and use it in GitHub Desktop.
Save SeanPONeil/10669730 to your computer and use it in GitHub Desktop.
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