Appcelerator Titanium Starting an Intent/Activity Not Firing

If you’re a user of intents with Android and Appcelerator’s Titanium product, you may have instances where your intents don’t fire as you expect. A lot of sample code around the web for starting intents looks something like this:

var intent = Ti.Android.createIntent({
    action: Ti.Android.ACTION_MAIN

The problem with arises when sometimes Ti.Android.currentActivity doesn’t correctly hold the current activity. When you then attempt to start an intent from the current activity, it does nothing. The way around this is to call startActivity from the current view, like this:


Which will fire the new intent every time.