Last active
August 29, 2015 13:59
-
-
Save SeanPONeil/10669730 to your computer and use it in GitHub Desktop.
receiveNotification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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