Created
April 22, 2015 02:38
-
-
Save Aiur3908/04a83b8f82c6e1f2a6b7 to your computer and use it in GitHub Desktop.
sendNotification
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
private void sendNotification() | |
{ | |
int notificationId = 001; | |
//決定這個notification的辨識編號 | |
NotificationCompat.Builder notificationBuilder = | |
new NotificationCompat.Builder(this) | |
.setSmallIcon(R.drawable.ic_launcher) | |
.setContentTitle("Title") | |
.setContentText("內容"); | |
//利用NotificationCompat.Builder來建立其內容 | |
NotificationManagerCompat notificationManager = | |
NotificationManagerCompat.from(this); | |
//取得NotificationManagerCompat的實體 | |
notificationManager.notify(notificationId, notificationBuilder.build()); | |
//填入辨識編號及notification後,即可發送出去 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment