Created
May 27, 2015 14:39
-
-
Save nightbear1009/dd8d5a02f9dd566888c0 to your computer and use it in GitHub Desktop.
heads-up 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
Intent notificationIntent = new Intent(MainActivity.this,MainActivity.class); | |
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0); | |
Notification notification = new Notification.Builder(MainActivity.this) | |
.setSmallIcon(R.drawable.ic_launcher) | |
.setFullScreenIntent(contentIntent, true) | |
.addAction(R.drawable.ic_launcher,"add",contentIntent) | |
.build(); | |
final int notifyID = 1; // 通知的識別號碼 | |
final NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); // 取得系統的通知服務 | |
notificationManager.notify(notifyID, notification); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment