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:

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.

Android Install Older Version of Build Tools

If you need to install an older version of Android’s build tools, you can do so using the below. Search for the SDK version you want:

Which will then give you an indexed list of SDKs:

and then you can install a specific package with the ID:

This blog post helped to discover the way to accomplish this.

Inspecting SQLite Databases in Appcelerator Titanium Projects

If you’re using SQLite for your project and you’d like to query the database directly. For Android based devices or emulators, you can do the following:

You’ll need to remember your database name, if you’re using commonJS, you can do something similar to:

Next, find out what devices you have connected using adb:

This will return a list similar to this:

Next, use the ADB shell command to boot into the device:

This will drop you into a shell on the device. Next, find the database file. In the first code snippet here, you can see our database name is app.db, so we’ll use a combination of find and grep to find the file on the device:

And this will return the SQLite file and it’s journal, like this:

Now you can use the CLI tool to open the database, like so:

And you’ll be dropped into the CLI tool. You can get a list of tables by using .tables and exit the program via .quit.

The reference for this post came from this wonderful blog post.

Fix: Titanium & GenyMotion Player Not Found

In the recent update of GenyMotion (Android Emulator) there’s a change which breaks its compatibility with Titanium Studio. You’ll need to open Terminal and create a symlink to fix it, start by opening Terminal and running:

and then type:

Shut Titanium Studio and GenyMotion both down and then restart Titanium Studio and it should work as usual after that point.