Created
February 28, 2014 12:48
-
-
Save fjallstrom/9270491 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@Override | |
public void onNotificationPosted(StatusBarNotification statusBarNotif) { | |
Notification notif = statusBarNotif.getNotification(); | |
if (notif != null){ | |
Bundle extras = notif.extras; | |
Intent intent = new Intent(MainActivity.INTENT_NOTIFICATION); | |
intent.putExtras(notif.extras); | |
sendBroadcast(intent); | |
Bundle intentExtras = intent.getExtras(); | |
String notifTitle = intentExtras.getString(Notification.EXTRA_TITLE); | |
CharSequence notifText = intentExtras.getCharSequence(Notification.EXTRA_TEXT); | |
int notificationId = statusBarNotif.getId(); | |
//Check if the notification is from snapchat, and the id matches the printscreen id from notification. | |
if(statusBarNotif.getPackageName().equals(snapchatPackageName)){ | |
if(notificationId == printScreenId){ | |
//Split the String to get the username. | |
String arr[] = notifText.toString().split(" ", 2); | |
String userName = arr[0]; | |
//Send to api. | |
runHttpPost(userName); | |
//Cancel all notifications. | |
NLService.this.cancelAllNotifications(); | |
} | |
} | |
else{ | |
Log.i("Other", "Another type of notification."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment