Created
July 12, 2012 01:56
-
-
Save yyl/3095164 to your computer and use it in GitHub Desktop.
Notification
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
| mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); | |
| // In this sample, we'll use the same text for the ticker and the expanded notification | |
| CharSequence text = getText(R.string.local_service_started); | |
| // The PendingIntent to launch our activity if the user selects this notification | |
| PendingIntent contentIntent = PendingIntent.getActivity(this, 0, | |
| new Intent(this, TrackingActivity.class), 0); | |
| builder = new NotificationCompat.Builder(getBaseContext()) | |
| .setContentTitle("You are being tracked...") | |
| .setContentText(text) | |
| .setSmallIcon(R.drawable.ic_launcher) | |
| .setContentIntent(contentIntent) | |
| .setOngoing(true); | |
| Notification notification = builder.getNotification(); | |
| // Send the notification. | |
| mNM.notify(NOTIFICATION, notification); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment