Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Starting activity from notification

$
0
0

I'd like to start (in Android) an Activity from an notification. I have created a new Alloy controller called 'outside'.

In my main file I have the following code which will display a notification. When pressed on this notification, it will start up the main activity (this needs to be replaced with an other activity).

var intent = Ti.Android.createIntent({ action: Ti.Android.ACTION_VIEW, flags : Ti.Android.FLAG_ACTIVITY_CLEAR_TOP | Ti.Android.FLAG_ACTIVITY_NEW_TASK, className: 'nl.domain.domain.DomainActivity' }); intent.addCategory(Ti.Android.CATEGORY_LAUNCHER);

var pending = Titanium.Android.createPendingIntent({ intent: intent, flags: Titanium.Android.FLAG_UPDATE_CURRENT });

var notification = Titanium.Android.createNotification({ icon: Ti.App.Android.R.drawable.estimote, contentTitle: 'Title', contentText : 'Text', tickerText: 'Text', contentIntent: pending });

Titanium.Android.NotificationManager.notify(1, notification);

How is it possible for me to open up a new activity in stead of the main activity?


Viewing all articles
Browse latest Browse all 8068

Trending Articles