Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-15443

Android: Allow full Activity lifecycle access for Titanium modules

    Details

    • Story Points:
      13
    • Sprint:
      2014 Sprint 21 SDK, 2014 Sprint 22 SDK

      Description

      The current Android module API offers access to the application lifecycle, but this is mostly irrelevant for Android (it's the iOS model!), where code needs access to the Activity lifecycle (i.e. onCreate, onResume, onPause, onStop, onDestroy, onActivityResult).

      A good example is this class in the Facebook SDK: https://developers.facebook.com/docs/reference/android/current/UiLifecycleHelper

      Currently, this class cannot be used in module code that runs in the context of a Window or TabGroup, since the module does not have access to that Activity's lifecycle events. This greatly complicates module porting to Titanium, since using such classes requires creating non-UI activities, and then we need methods to sync between the various Activities.

      Proposal

      1. Add a new dictionary parameter to Ti.UI.createWindow and createTabGroup, attachAndroidModule: 'modulename'
      2. If attachAndroidModule is specified, the module is loaded prior to Activity creation and its lifecycle events correspond to those of the created UI Activity.
      3. The Javascript does not change - the module is "required" and used as before.
      4. Clearly the module can be attached to multiple Activities in a Titanium app - just as an Android library can be used by multiple Activities in in a native Android app, and in each case the events correspond to the Activity in use.
      5. I would deprecate the current lifecycle events in the Android module, since they're confusing in the Android context. However, if desired, I suppose it's possible to maintain "legacy" module behavior (per module) through tiapp.xml configuration parameters.

      This is yet another stumbling block to easy porting of 3rd party code. The Titanium community would greatly benefit from this improvement.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jalter Jon Alter
                Reporter:
                mokesmokes Mark Mokryn
              • Watchers:
                13 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration