Created
April 14, 2014 16:18
-
-
Save rblalock/10662361 to your computer and use it in GitHub Desktop.
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 activity = Ti.Android.currentActivity; | |
var intent = Ti.Android.createIntent({ | |
action : Ti.Android.ACTION_MAIN, | |
// you can use className or url to launch the app | |
// className and packageName can be found by looking in the build folder | |
// for example, mine looked like this | |
// build/android/gen/com/appcelerator/test/Test7Activity.java | |
// className : 'com.appcelerator.test.Test7Activity', | |
// if you use url, you need to make some changes to your tiapp.xml | |
url : 'app.js', | |
flags : Ti.Android.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Ti.Android.FLAG_ACTIVITY_SINGLE_TOP | |
}); | |
intent.addCategory(Titanium.Android.CATEGORY_LAUNCHER); | |
var pending = Ti.Android.createPendingIntent({ | |
activity : activity, | |
intent : intent, | |
type : Ti.Android.PENDING_INTENT_FOR_ACTIVITY, | |
flags : Ti.Android.FLAG_ACTIVITY_NO_HISTORY | |
}); | |
var notification = Ti.Android.createNotification({ | |
contentIntent : pending, | |
contentTitle : 'Test', | |
contentText : 'test', | |
tickerText : 'This is a test', | |
// "when" will only put the timestamp on the notification and nothing else. | |
// Setting it does not show the notification in the future | |
when : new Date().getTime(), | |
icon : Ti.App.Android.R.drawable.appicon, | |
flags : Titanium.Android.ACTION_DEFAULT | Titanium.Android.FLAG_AUTO_CANCEL | Titanium.Android.FLAG_SHOW_LIGHTS | |
}); | |
Ti.Android.NotificationManager.notify(1, 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
<android xmlns:android="http://schemas.android.com/apk/res/android"> | |
<!-- the activities tag must be added if you want to use the url property to launch your app --> | |
<activities> | |
<activity url="app.js"> | |
<intent-filter> | |
<action android:name="android.intent.action.VIEW"/> | |
<category android:name="android.intent.category.DEFAULT"/> | |
<category android:name="android.intent.category.BROWSABLE"/> | |
</intent-filter> | |
</activity> | |
</activities> | |
</android> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment