Created
May 26, 2012 14:22
-
-
Save anonymous/2794118 to your computer and use it in GitHub Desktop.
Android 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
| var win = Ti.UI.createWindow({ | |
| backgroundColor : 'gray' | |
| }); | |
| var btn = Ti.UI.createButton({ | |
| title: 'Notification' | |
| }); | |
| btn.addEventListener('click', function(e) { | |
| alert('Bingo!'); | |
| var intent = Titanium.Android.createIntent({ | |
| action: Titanium.Android.ACTION_MAIN, | |
| className: 'br.com.royalsoft.notificacao.NotificacaoActivity', | |
| packageName: 'br.com.royalsoft.notificacao' | |
| }); | |
| intent.addCategory(Titanium.Android.CATEGORY_LAUNCHER); | |
| var pending = Titanium.Android.createPendingIntent({ | |
| activity: Titanium.Android.currentActivity, | |
| intent: intent, | |
| type: Titanium.Android.PENDING_INTENT_FOR_ACTIVITY, | |
| flags: Titanium.Android.FLAG_ACTIVITY_NEW_TASK | |
| }); | |
| // Create the notification | |
| var notification = Titanium.Android.createNotification({ | |
| // icon is passed as an Android resource ID -- see Ti.App.Android.R. | |
| icon: Ti.App.Android.R.drawable.my_icon, | |
| contentTitle: 'Something Happened', | |
| contentText : 'Click to return to the application.', | |
| contentIntent: pending | |
| }); | |
| // Send the notification. | |
| Titanium.Android.NotificationManager.notify(1, notification); | |
| }); | |
| win.add(btn); | |
| win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment