Created
February 12, 2015 06:22
-
-
Save Tikitoo/28558a0ad43a3826c88a to your computer and use it in GitHub Desktop.
Create a Notification demo
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
public void onCreate() { | |
super.onCreate(); | |
Log.d(TAG, "onCreate Method"); | |
// 创建Notification 对象 | |
Notification notif = new Notification(R.drawable.abc_ic_menu_cut_mtrl_alpha, | |
"This is Notification", System.currentTimeMillis()); | |
// 点击Notification 进入MainActivity | |
Intent notifIntent = new Intent(this, MainActivity.class); | |
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, | |
notifIntent, 0); | |
// 设置Notification 详细信息 | |
notif.setLatestEventInfo(this, "title", "This is Notification content", | |
pendingIntent); | |
startForeground(1, notif); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment