-
-
Save deRonbrown/939e4956effaa9528215 to your computer and use it in GitHub Desktop.
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
String message = "Test Message"; | |
CharSequence appName = "Test App"; | |
int appIcon = android.R.drawable.sym_def_app_icon; | |
try { | |
ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), 0); | |
appName = context.getPackageManager().getApplicationLabel(applicationInfo); | |
appIcon = applicationInfo.icon; | |
} catch (PackageManager.NameNotFoundException e) {} | |
Notification notification = new Notification(appIcon, message, System.currentTimeMillis()); | |
notification.flags |= Notification.FLAG_AUTO_CANCEL; | |
Intent launchIntent = new Intent(this, TestActivity.class); | |
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launchIntent, PendingIntent.FLAG_UPDATE_CURRENT); | |
notification.setLatestEventInfo(context, appName, message, contentIntent); | |
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); | |
notificationManager.notify(campaignId, notification); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment