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

How to use newIntent event?

$
0
0

Hello everybody. I am trying to find how to use in the newIntent event with no success. In my code i just started new service:

androidService.js

var service = Titanium.Android.currentService;
 
var intent = service.intent;
 
var intent1 = Ti.Android.createIntent({
    //flags : Ti.Android.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Ti.Android.FLAG_ACTIVITY_SINGLE_TOP,
    className : "com.myprogram.AndroidServiceService",
    packageName : 'com.myprogram',
    action : 1
});
intent1.putExtra('button', 'my first activity');
 
var pending1 = Titanium.Android.createPendingIntent({
    activity : Titanium.Android.currentActivity,
    intent : intent1,
    type : Titanium.Android.PENDING_INTENT_FOR_ACTIVITY,
    flags : Titanium.Android.FLAG_UPDATE_CURRENT
});
 
var customView = Ti.Android.createRemoteViews({
    layoutId : Ti.App.Android.R.layout.customview
});
 
customView.setTextViewText(Ti.App.Android.R.id.okbutton, "send");
customView.setOnClickPendingIntent(Ti.App.Android.R.id.okbutton, pending1);
 
var notification = Titanium.Android.createNotification({
    contentView : customView
});
 
Ti.Android.NotificationManager.notify(1, notification);
 
Ti.Android.currentActivity.addEventListener('newintent', function(e) {
    Ti.API.info('caught intent!');
    if (e.intent.hasExtra('button')) {
        Ti.API.info(e.intent.getStringExtra('button'));
    } else {
        Ti.API.info('no button data');
    }
});
The newintent never called. can someone help me to figure out this issue? Thank's a lot!

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>