I'm creating an Android app using Titanium appcelerator(using alloy), I create a status bar notification, the issue is when the notification appears, I want open a specific window and pass it some data when the user taps the notification, so my code is:
// Intent object to launch the application var intent = Ti.Android.createIntent({ action : Ti.Android.ACTION_MAIN, flags : Ti.Android.FLAG_ACTIVITY_CLEAR_TOP | Ti.Android.FLAG_ACTIVITY_NEW_TASK, url : "window.js" }); intent.addCategory(Ti.Android.CATEGORY_LAUNCHER); intent.putExtra("id", "10"); var activity = Ti.Android.currentActivity; // Create a PendingIntent to tie together the Activity and Intent var pending = Titanium.Android.createPendingIntent({ activity : activity, intent : intent, type : Ti.Android.PENDING_INTENT_FOR_ACTIVITY, flags : Titanium.Android.FLAG_CANCEL_CURRENT }); // 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.appicon, contentTitle : 'Something Happened', contentText : 'Click to return to the application.', contentIntent : pending, flags : Ti.Android.ACTION_DEFAULT | Ti.Android.FLAG_AUTO_CANCEL | Ti.Android.FLAG_SHOW_LIGHTS }); // Send the notification. Titanium.Android.NotificationManager.notify(1, notification);when the user taps the notification, indeed, the app comes to front, but in the same window where was left, not exactly the wanted window.
I'm almost there, give me a little push.
Thanks.