Tuesday, January 22, 2013

Gotcha of the Day: Setting up an Adobe AIR App to run as a Launcher on Android

One of my customer's wants to turn a collection of Android tablets into devices that just run their Adobe AIR Android App. Effectively, they want them to run in a kiosk mode.

My thought was that I'd have to either leverage an existing app launcher, or code my own, to support this. Turns out, it's much easier than this. I found the answer clearly spelled out here:

Making an application that can be installed as a Home Screen is simple; you just have to add the HOME intent category to the main Activity's intent filter.

Hard to believe, but all one needs to do is to hack the AndroidManifest.xml and you're all set.

This is slightly tricky in the Adobe AIR world because: (a) you don't have direct access to the AndroidManifest.xml and (b) you don't directly create or name the specific activity that gets run in the app. It took fiddling, but I solved both these issues by putting the following in my Air App's application descriptor:

<?xml version="1.0" encoding="utf-8" ?>
<application xmlns="http://ns.adobe.com/air/application/3.1">

  <!-- standard descriptor stuff goes here -->

  <android>
    <manifestAdditions><![CDATA[
      <manifest>
        <!-- other android manifest stuff, like permissions, go here -->
        
        <application>
          <activity android:name=".AppEntry"> 
            <intent-filter> 
              <action android:name="android.intent.action.MAIN" />
              <category android:name="android.intent.category.HOME"/> 
              <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>     
          </activity>
        </application>
      </manifest>
    ]]></manifestAdditions>
  </android>
</application>

Setting android:name=".AppEntry" is especially key, otherwise the device won't be able to start your application up properly.

Once you've updated your deployment descriptor and rebuilt and installed the apk file, you must do the following:

  1. Click on the home button on your device
  2. You should get a system dialog asking you which application should complete the action
  3. Choose your application and click 'Always'
  4. Reboot your device
  5. Confirm, when it starts up, that the only application available is yours

If all went well, you'll have turned your general purpose tablet or phone into a one-app-wonder.

To get things back to normal, remove your app using a tool like adb.exe or MobileGo from Wondershare. I don't know much about the later option, other than it's quite a bit more user friendly than adb.exe, so it may be more appropriate to an audience who just wants to experiment with the kiosk app you've built.

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails