<commit_before>---
name: Titanium.Android.Activity
summary: The Titanium binding of an Android Activity.
description: |
    According to the Android API Reference, an activity is "a single, focused thing that a
    user can do."

    In almost all cases, an activity is associated with a window.  Activities are central
    to the Android **Back** button navigation -- the **Back** button closes the current
    activity and returns to whatever activity was open previously.

    In Titanium, the Android Activity is not created until a window or tab group is opened.
    After a Window or TabGroup object is created but before it is opened, its `activity` property
    refers to an empty JavaScript object. You can use it to set properties on the activity, such as
    the `onCreateOptionsMenu` property, but you cannot invoke any Activity methods.

    After the window or tab group opens, a real Activity object is created and the properties from
    the JavaScript object are copied over. The `activity` property now refers to this real Activity object,
    which you can use to call the various Activity methods. For example, to use the
    `invalidateOptionsMenu` method, you need to get the activity after the window or tab group opens.

    See also [android.app.Activity](http://developer.android.com/reference/android/app/Activity.html)
    in the Android API Reference.

    #### Activity Lifecycle

    In Android, activities are created, started, resumed, paused, stopped, destroyed and restarted.
    Titanium generates lifecycle events for activities but does not generate application-level events.
    To be notified when an activity's lifecycle event is triggered, assign callbacks to the following activity
    properties:

      * [onCreate](Titanium.Android.Activity.onCreate)
      * [onStart](Titanium.Android.Activity.onStart)
      * [onResume](Titanium.Android.Activity.onResume)
      * [onPause](Titanium.Android.Activity.onPause)
      * [onStop](Titanium.Android.Activity.onStop)
      * [onDestroy](Titanium.Android.Activity.onDestroy)
      * [onRestart](Titanium.Android.Activity.onRestart)

    See also the "Understand the Lifecycle Callbacks" section in
    [Android Developers: Activity Lifecycle](http://developer.android.com/training/basics/activity-lifecycle/starting.html).

    #### Don't keep activities option

    Android 4.0 and greater devices have an option called **Don't keep activities** under the **Developer
    Options** menu. When this option is enabled, the Android OS will destroy an activity as soon as it
    is stopped. It is intended to help developers debug their apps. For example, it can simulate the
    case that Android will kill an activity in the background due to memory pressure. In
    normal use, it is not recommended to turn this option on because this may lead to unexpected issues
    on the apps, such as freezes, force closes and reboots.

    When the **Don't keep activities** option is enabled, the lifecycle of the activity is different
    from the normal case. Whenever the user leaves an activity, such as backgrounding the app using the
    HOME button, this activity is destroyed by Android, which calls `onDestroy`.  In the normal case, `onStop`
    would be called and the activity would not be destroyed.  Later, when the user goes back to that activity, this
    activity will be recreated, which calls `onCreate`.  In the normal case, since the activity is not destroyed, 
    `onRestart` would be called instead.  Therefore, some events, such as the open and close events on the Window
    or TabGroup, will be fired differently from the normal case, and the root window of the app must set
    [exitOnClose](Titanium.UI.Window.exitOnClose) to true; otherwise, the app will be unable to back out, that is,
    hitting the BACK button in the root window will not allow the application to exit.

    #### Deprecated Behavior

    Prior to Release 3.4.0, to monitor lifecycle events, use the activity's events, `create`, `destroy`,
    `pause`, `resume`, `start` and `stop`, to be notified when an activity is created, destroyed, paused,
    resumed, started and stopped, respectively.

    You can only set Activity properties from a TabGroup object after the tab group opens.

    Prior to Release 3.2.0, you can create either a "lightweight" or "heavyweight" window, as
    described on the <Titanium.UI.Window> reference page. A *heavyweight* window creates a 
    new `Activity`. A *lightweight* window runs inside the same activity as the code that
    created it.  If you try to reference the activity of lightweight window, it returns undefined.


extends: Titanium.Proxy
platforms: [android]
createable: false
since: "1.5"
methods:
  - name: finish
    summary: Closes this activity.
    description: |
        See also:
        [finish](http://developer.android.com/reference/android/app/Activity.html#finish())
        in the Android API Reference.

  - name: getString
    summary: Gets an Android or Application string using the specified Resource ID and optional format arguments. 
    description: |
        If the optional format arguments are supplied, these are substituted for the
        corresponding format specifiers in the string. For example, given the following
        string resource:

            <string name="greeting">"Hello %1$s, this is %2$s."</string>

        You could call `getString` like this:

            Ti.Android.currentActivity.getString(Ti.App.Android.R.string.greeting,  "Bob", "Doug" );

        The resulting string is:

            "Hello Bob, this is Doug."

        See also:
        *   [getString](http://developer.android.com/reference/android/content/Context.html#getString(int))
            in the Android Developer Reference
        *   [Formatter](http://developer.android.com/reference/java/util/Formatter.html)
            in the Android Developer Reference
        *   [String Resources](http://developer.android.com/guide/topics/resources/string-resource.html#String)
            in the Android Developer Guide
    returns:
        type: String
    parameters:
      - name: resourceId
        summary: Resource ID from the Application or Android.
        type: Number

      - name: format
        summary: Optional format arguments for the String resource. May be repeated.
        type: Object

  - name: invalidateOptionsMenu
    summary: Declares that the option menu has changed and should be recreated.
    description: |
        This method needs to be used in Android 3.0 and above when changing menus at runtime.  See
        [changingTheMenu](http://developer.android.com/guide/topics/ui/menus.html#ChangingTheMenu) in 
        the Android API Reference for more details. 
    since: "3.0.0"

  - name: setRequestedOrientation
    summary: Sets the requested Activity orientation. 
    description: |
        See also:
        [setRequestedOrientation](http://developer.android.com/reference/android/app/Activity.html#setRequestedOrientation(int))
        in the Android API Reference.
    parameters:
      - name: orientation
        summary: Orientation mode for the activity.
        constants: Titanium.Android.SCREEN_ORIENTATION_*
        type: Number

  - name: setResult
    summary: Sets the result of this activity using an `Intent`. 
    description: |
        This should be used in the case when the Activity responds to
        [startActivityForResult](Titanium.Android.Activity.startActivityForResult). 

        Also see Android's documentation for
        [setResult](http://developer.android.com/reference/android/app/Activity.html#setResult(int)).
    parameters:

      - name: resultCode
        summary: Result code for this activity.
        constants: Titanium.Android.RESULT_*
        type: Number

      - name: intent
        summary: An optional `Intent` with extra result data.
        type: Titanium.Android.Intent
        optional: true

  - name: startActivity
    summary: Starts a new activity, using the passed in `Intent` as the description. 
    description: |
        See also: [startActivity](http://developer.android.com/reference/android/app/Activity.html#startActivity(android.content.Intent))
            in the Android Developer Reference.
    parameters:
      - name: intent
        summary: Description of the activity to start.
        type: Titanium.Android.Intent

  - name: startActivityForResult
    summary: The same as `startActivity`, but also accepts a callback function for handling the result of the started Activity. 
    description:  |
        See also: 
        [startActivityForResult](http://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)) 
        in the Android Developer Reference.
    parameters:

      - name: intent
        summary: Description of the activity to start.
        type: Titanium.Android.Intent

      - name: callback
        summary: |
            Callback function to be executed when the activity sets result. See
            examples.
        type: Callback<ActivityResult>
        
  - name: openOptionsMenu
    summary: Programmatically opens the options menu.
    description: |
        See also: [onMenuOpened](http://developer.android.com/reference/android/app/Activity.html#onMenuOpened(int, android.view.Menu))
        in the Android API Reference.
    since: "3.0.0"
    
  - name: sendBroadcast
    summary: Broadcast the passed in `Intent` to all `BroadcastReceiver`s. 
    since: "3.2.0"
    parameters:
      - name: intent
        summary: Description of the broadcast.
        type: Titanium.Android.Intent

  - name: sendBroadcastWithPermission
    summary: Broadcast the passed in `Intent` to all `BroadcastReceiver`s with an optional permission.
    since: "3.2.0"
    parameters:
      - name: intent
        summary: Description of the broadcast.
        type: Titanium.Android.Intent
      - name: receiverPermission
        summary: Name of the permission that the receiver should hold in order to receive the broadcast.
        type: String
        optional: true
events:

  - name: create
    summary: Fired from the activity's `onCreate` method.
    deprecated:
        since: "3.4.0"
        notes: Use the [onCreate](Titanium.Android.Activity.onCreate) property instead.
    description: |
        See also:
        [onCreate](http://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle))
        in the Android Developer Reference.

  - name: destroy
    summary: Fired from the activity's `onDestroy` method.
    deprecated:
        since: "3.4.0"
        notes: Use the [onDestroy](Titanium.Android.Activity.onDestroy) property instead.
    description: |
        See also: [onDestroy](http://developer.android.com/reference/android/app/Activity.html#onDestroy())
        in the Android Developer Reference.

  - name: newIntent
    deprecated:
        since: "3.0.0"
        notes: |
            Renamed to [newintent](Titanium.Android.Activity.newintent)
            (all lowercase).
    summary: Fired when the activity is already running and certain flags are set in its intent. 
    description: |
        See also:
        [onNewIntent](http://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent))
        in the Android Developer Reference.
    properties:
      - name: intent
        summary: The `Intent` passed to the native `onNewIntent` method.
        type: Titanium.Android.Intent

  - name: newintent
    summary: Fired when the activity is already running and certain flags are set in its intent. 
    description: |
        See also:
        [onNewIntent](http://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent))
        in the Android Developer Reference.
    properties:
      - name: intent
        summary: The `Intent` passed to the native `onNewIntent` method.
        type: Titanium.Android.Intent
    since: '3.0.0'

  - name: pause
    summary: Fired when the activity is paused.
    deprecated:
        since: "3.4.0"
        notes: Use the [onPause](Titanium.Android.Activity.onPause) property instead.
    description: |
        See also:
        [onPause](http://developer.android.com/reference/android/app/Activity.html#onPause())
        in the Android Developer Reference.

  - name: resume
    summary: Fired when the activity is resumed.
    deprecated:
        since: "3.4.0"
        notes: Use the [onResume](Titanium.Android.Activity.onResume) property instead.
    description: |
        See also: [onResume](http://developer.android.com/reference/android/app/Activity.html#onResume())
        in the Android Developer Reference.

  - name: start
    summary: Fired when the activity is started.
    deprecated:
        since: "3.4.0"
        notes: Use the [onStart](Titanium.Android.Activity.onStart) property instead.
    description: |
        See also: [onStart](http://developer.android.com/reference/android/app/Activity.html#onStart())
        in the Android Developer Reference.

  - name: stop
    summary: Fired when the activity is stopped.
    deprecated:
        since: "3.4.0"
        notes: Use the [onStop](Titanium.Android.Activity.onStop) property instead.
    description: |
        See also: [onStop](http://developer.android.com/reference/android/app/Activity.html#onStop())
        in the Android Developer Reference.

  - name: userleavehint
    summary: Fired when the activity is about to go into the background as a result of user choice.
    description: |
        See also:
        [onPause](http://developer.android.com/reference/android/app/Activity.html#onUserLeaveHint())
        in the Android Developer Reference.
    since: "3.2.0"


properties:

  - name: actionBar
    summary: The action bar for this activity.
    description: |
        See also: [Action Bar](http://developer.android.com/guide/topics/ui/actionbar.html) in
        the Android Developer Reference.
    type: Titanium.Android.ActionBar
    permission: read-only

  - name: intent
    summary: The `Intent` that was used to start this Activity.
    type: Titanium.Android.Intent
    permission: read-only

  - name: onCreate
    summary: |
        Callback function called when the Android activity is created.
    since: "3.4.0"
    type: Callback<Object>

  - name: onCreateOptionsMenu
    summary: |
        Callback function called to initially create an Android options menu
        for this Activity when the user presses the **Menu** button.
    description: |
         See the menu examples in <Titanium.Android.Menu>.

         See also: 
         [Creating an Options Menu](http://developer.android.com/guide/topics/ui/menus.html#options-menu) 
         in the Android Developer's Guide.
    type: Callback<Object>

  - name: onDestroy
    summary: |
        Callback function called when the Android activity is destroyed.
    since: "3.4.0"
    type: Callback<Object>

  - name: onPause
    summary: |
        Callback function called when the Android activity is paused.
    since: "3.4.0"
    type: Callback<Object>

  - name: onPrepareOptionsMenu
    summary:  |
        Callback function called to prepare an options menu for display when the user presses
        the **Menu** button. 
    description: |
         See the menu examples in <Titanium.Android.Menu>.

         See also: 
         [Creating an Options Menu](http://developer.android.com/guide/topics/ui/menus.html#options-menu) 
         in the Android Developer's Guide.
    type: Callback<Object>

  - name: onRestart
    summary: |
        Callback function called when the Android activity is restarted.
    since: "3.4.0"
    type: Callback<Object>

  - name: onResume
    summary: |
        Callback function called when the Android activity is resumed.
    since: "3.4.0"
    type: Callback<Object>

  - name: onStart
    summary: |
        Callback function called when the Android activity is started.
    since: "3.4.0"
    type: Callback<Object>

  - name: onStop
    summary: |
        Callback function called when the Android activity is stopped.
    since: "3.4.0"
    type: Callback<Object>

  - name: requestedOrientation
    summary: Specifies a specific orientation for this activity.
    constants: Titanium.Android.SCREEN_ORIENTATION_*
    type: Number
    permission: write-only

examples:
  - title: Callback Example
    example: |
        The following example shows how to start an activity and retrieve a result code
        and optional data intent when the activity ends.
        
            activity.startActivityForResult(intent, function(e) {
                // The request code used to start this Activity
                var requestCode = e.requestCode;
                // The result code returned from the activity 
                // (http://developer.android.com/reference/android/app/Activity.html#StartingActivities)
                var resultCode = e.resultCode;
                // A Titanium.Android.Intent filled with data returned from the Activity
                var intent = e.intent;
                // The Activity the received the result
                var source = e.source;
            });
        
---
name: ActivityResult
summary: |
    Simple object passed to the
    [startActivityForResult](Titanium.Android.Activity.startActivityForResult) callback.
properties:

  - name: requestCode
    summary: |
        Unique, automatically generated integer request code.
    type: Number

  - name: resultCode
    summary: |
        Integer result code that the started activity passed to
        [setResult](Titanium.Android.Activity.setResult).
    type: Number

  - name: intent
    summary: |
        Intent that can contain data returned to the caller. Data can be attached to
        the intent as "extras").
    type: Titanium.Android.Intent

<commit_msg>Added info about handling application restarts.<commit_after>---
name: Titanium.Android.Activity
summary: The Titanium binding of an Android Activity.
description: |
    According to the Android API Reference, an activity is "a single, focused thing that a
    user can do."

    In almost all cases, an activity is associated with a window.  Activities are central
    to the Android **Back** button navigation -- the **Back** button closes the current
    activity and returns to whatever activity was open previously.

    In Titanium, the Android Activity is not created until a window or tab group is opened.
    After a Window or TabGroup object is created but before it is opened, its `activity` property
    refers to an empty JavaScript object. You can use it to set properties on the activity, such as
    the `onCreateOptionsMenu` property, but you cannot invoke any Activity methods.

    After the window or tab group opens, a real Activity object is created and the properties from
    the JavaScript object are copied over. The `activity` property now refers to this real Activity object,
    which you can use to call the various Activity methods. For example, to use the
    `invalidateOptionsMenu` method, you need to get the activity after the window or tab group opens.

    See also [android.app.Activity](http://developer.android.com/reference/android/app/Activity.html)
    in the Android API Reference.

    #### Activity Lifecycle

    In Android, activities are created, started, resumed, paused, stopped, destroyed and restarted.
    Titanium generates lifecycle events for activities but does not generate application-level events.
    To be notified when an activity's lifecycle event is triggered, assign callbacks to the following activity
    properties:

      * [onCreate](Titanium.Android.Activity.onCreate)
      * [onStart](Titanium.Android.Activity.onStart)
      * [onResume](Titanium.Android.Activity.onResume)
      * [onPause](Titanium.Android.Activity.onPause)
      * [onStop](Titanium.Android.Activity.onStop)
      * [onDestroy](Titanium.Android.Activity.onDestroy)
      * [onRestart](Titanium.Android.Activity.onRestart)

    See also the "Understand the Lifecycle Callbacks" section in
    [Android Developers: Activity Lifecycle](http://developer.android.com/training/basics/activity-lifecycle/starting.html).

    #### Handling Application Restarts 

    Every Android application has a root activity that starts the application. For Titanium
    applications, the root activity displays the splash screen. When a backgrounded
    application is left inactive (for about 30 minutes or so) Android, upon reopening the app,
    kills off activities above the root activity. This reveals the splash screen activity, making it 
    appear as if the application is hung. There are two ways to handle this scenario:

    * Add the following to the root `<ti:app>` element in your project's tiapp.xml:

            <property name="ti.android.root.reappears.restart" type="bool">true</property>

    * Create an event listener for the `"resume"` event on the current Android activity that
    re-intiializes the application. The benefit to this approach is that it avoids a full
    application restart, which occurs with the first option.

            var initialLaunchPerformed = false;
            Ti.Android.currentActivity.addEventListener("resume", function() {
                if (!initialLaunchPerformed) {
                    initialLaunchPerformed = true;
                    return;
                }
                // If we reach this point the root activity is being resumed for the second (or greater time).
                // Re-run the application-specific start-up code again.
                runApplication();
            });   

            function runApplication() {
                // Start-up code here...
            }

    #### Don't keep activities option

    Android 4.0 and greater devices have an option called **Don't keep activities** under the **Developer
    Options** menu. When this option is enabled, the Android OS will destroy an activity as soon as it
    is stopped. It is intended to help developers debug their apps. For example, it can simulate the
    case that Android will kill an activity in the background due to memory pressure. In
    normal use, it is not recommended to turn this option on because this may lead to unexpected issues
    on the apps, such as freezes, force closes and reboots.

    When the **Don't keep activities** option is enabled, the lifecycle of the activity is different
    from the normal case. Whenever the user leaves an activity, such as backgrounding the app using the
    HOME button, this activity is destroyed by Android, which calls `onDestroy`.  In the normal case, `onStop`
    would be called and the activity would not be destroyed.  Later, when the user goes back to that activity, this
    activity will be recreated, which calls `onCreate`.  In the normal case, since the activity is not destroyed, 
    `onRestart` would be called instead.  Therefore, some events, such as the open and close events on the Window
    or TabGroup, will be fired differently from the normal case, and the root window of the app must set
    [exitOnClose](Titanium.UI.Window.exitOnClose) to true; otherwise, the app will be unable to back out, that is,
    hitting the BACK button in the root window will not allow the application to exit.

    #### Deprecated Behavior

    Prior to Release 3.4.0, to monitor lifecycle events, use the activity's events, `create`, `destroy`,
    `pause`, `resume`, `start` and `stop`, to be notified when an activity is created, destroyed, paused,
    resumed, started and stopped, respectively.

    You can only set Activity properties from a TabGroup object after the tab group opens.

    Prior to Release 3.2.0, you can create either a "lightweight" or "heavyweight" window, as
    described on the <Titanium.UI.Window> reference page. A *heavyweight* window creates a 
    new `Activity`. A *lightweight* window runs inside the same activity as the code that
    created it.  If you try to reference the activity of lightweight window, it returns undefined.


extends: Titanium.Proxy
platforms: [android]
createable: false
since: "1.5"
methods:
  - name: finish
    summary: Closes this activity.
    description: |
        See also:
        [finish](http://developer.android.com/reference/android/app/Activity.html#finish())
        in the Android API Reference.

  - name: getString
    summary: Gets an Android or Application string using the specified Resource ID and optional format arguments. 
    description: |
        If the optional format arguments are supplied, these are substituted for the
        corresponding format specifiers in the string. For example, given the following
        string resource:

            <string name="greeting">"Hello %1$s, this is %2$s."</string>

        You could call `getString` like this:

            Ti.Android.currentActivity.getString(Ti.App.Android.R.string.greeting,  "Bob", "Doug" );

        The resulting string is:

            "Hello Bob, this is Doug."

        See also:
        *   [getString](http://developer.android.com/reference/android/content/Context.html#getString(int))
            in the Android Developer Reference
        *   [Formatter](http://developer.android.com/reference/java/util/Formatter.html)
            in the Android Developer Reference
        *   [String Resources](http://developer.android.com/guide/topics/resources/string-resource.html#String)
            in the Android Developer Guide
    returns:
        type: String
    parameters:
      - name: resourceId
        summary: Resource ID from the Application or Android.
        type: Number

      - name: format
        summary: Optional format arguments for the String resource. May be repeated.
        type: Object

  - name: invalidateOptionsMenu
    summary: Declares that the option menu has changed and should be recreated.
    description: |
        This method needs to be used in Android 3.0 and above when changing menus at runtime.  See
        [changingTheMenu](http://developer.android.com/guide/topics/ui/menus.html#ChangingTheMenu) in 
        the Android API Reference for more details. 
    since: "3.0.0"

  - name: setRequestedOrientation
    summary: Sets the requested Activity orientation. 
    description: |
        See also:
        [setRequestedOrientation](http://developer.android.com/reference/android/app/Activity.html#setRequestedOrientation(int))
        in the Android API Reference.
    parameters:
      - name: orientation
        summary: Orientation mode for the activity.
        constants: Titanium.Android.SCREEN_ORIENTATION_*
        type: Number

  - name: setResult
    summary: Sets the result of this activity using an `Intent`. 
    description: |
        This should be used in the case when the Activity responds to
        [startActivityForResult](Titanium.Android.Activity.startActivityForResult). 

        Also see Android's documentation for
        [setResult](http://developer.android.com/reference/android/app/Activity.html#setResult(int)).
    parameters:

      - name: resultCode
        summary: Result code for this activity.
        constants: Titanium.Android.RESULT_*
        type: Number

      - name: intent
        summary: An optional `Intent` with extra result data.
        type: Titanium.Android.Intent
        optional: true

  - name: startActivity
    summary: Starts a new activity, using the passed in `Intent` as the description. 
    description: |
        See also: [startActivity](http://developer.android.com/reference/android/app/Activity.html#startActivity(android.content.Intent))
            in the Android Developer Reference.
    parameters:
      - name: intent
        summary: Description of the activity to start.
        type: Titanium.Android.Intent

  - name: startActivityForResult
    summary: The same as `startActivity`, but also accepts a callback function for handling the result of the started Activity. 
    description:  |
        See also: 
        [startActivityForResult](http://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)) 
        in the Android Developer Reference.
    parameters:

      - name: intent
        summary: Description of the activity to start.
        type: Titanium.Android.Intent

      - name: callback
        summary: |
            Callback function to be executed when the activity sets result. See
            examples.
        type: Callback<ActivityResult>
        
  - name: openOptionsMenu
    summary: Programmatically opens the options menu.
    description: |
        See also: [onMenuOpened](http://developer.android.com/reference/android/app/Activity.html#onMenuOpened(int, android.view.Menu))
        in the Android API Reference.
    since: "3.0.0"
    
  - name: sendBroadcast
    summary: Broadcast the passed in `Intent` to all `BroadcastReceiver`s. 
    since: "3.2.0"
    parameters:
      - name: intent
        summary: Description of the broadcast.
        type: Titanium.Android.Intent

  - name: sendBroadcastWithPermission
    summary: Broadcast the passed in `Intent` to all `BroadcastReceiver`s with an optional permission.
    since: "3.2.0"
    parameters:
      - name: intent
        summary: Description of the broadcast.
        type: Titanium.Android.Intent
      - name: receiverPermission
        summary: Name of the permission that the receiver should hold in order to receive the broadcast.
        type: String
        optional: true
events:

  - name: create
    summary: Fired from the activity's `onCreate` method.
    deprecated:
        since: "3.4.0"
        notes: Use the [onCreate](Titanium.Android.Activity.onCreate) property instead.
    description: |
        See also:
        [onCreate](http://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle))
        in the Android Developer Reference.

  - name: destroy
    summary: Fired from the activity's `onDestroy` method.
    deprecated:
        since: "3.4.0"
        notes: Use the [onDestroy](Titanium.Android.Activity.onDestroy) property instead.
    description: |
        See also: [onDestroy](http://developer.android.com/reference/android/app/Activity.html#onDestroy())
        in the Android Developer Reference.

  - name: newIntent
    deprecated:
        since: "3.0.0"
        notes: |
            Renamed to [newintent](Titanium.Android.Activity.newintent)
            (all lowercase).
    summary: Fired when the activity is already running and certain flags are set in its intent. 
    description: |
        See also:
        [onNewIntent](http://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent))
        in the Android Developer Reference.
    properties:
      - name: intent
        summary: The `Intent` passed to the native `onNewIntent` method.
        type: Titanium.Android.Intent

  - name: newintent
    summary: Fired when the activity is already running and certain flags are set in its intent. 
    description: |
        See also:
        [onNewIntent](http://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent))
        in the Android Developer Reference.
    properties:
      - name: intent
        summary: The `Intent` passed to the native `onNewIntent` method.
        type: Titanium.Android.Intent
    since: '3.0.0'

  - name: pause
    summary: Fired when the activity is paused.
    deprecated:
        since: "3.4.0"
        notes: Use the [onPause](Titanium.Android.Activity.onPause) property instead.
    description: |
        See also:
        [onPause](http://developer.android.com/reference/android/app/Activity.html#onPause())
        in the Android Developer Reference.

  - name: resume
    summary: Fired when the activity is resumed.
    deprecated:
        since: "3.4.0"
        notes: Use the [onResume](Titanium.Android.Activity.onResume) property instead.
    description: |
        See also: [onResume](http://developer.android.com/reference/android/app/Activity.html#onResume())
        in the Android Developer Reference.

  - name: start
    summary: Fired when the activity is started.
    deprecated:
        since: "3.4.0"
        notes: Use the [onStart](Titanium.Android.Activity.onStart) property instead.
    description: |
        See also: [onStart](http://developer.android.com/reference/android/app/Activity.html#onStart())
        in the Android Developer Reference.

  - name: stop
    summary: Fired when the activity is stopped.
    deprecated:
        since: "3.4.0"
        notes: Use the [onStop](Titanium.Android.Activity.onStop) property instead.
    description: |
        See also: [onStop](http://developer.android.com/reference/android/app/Activity.html#onStop())
        in the Android Developer Reference.

  - name: userleavehint
    summary: Fired when the activity is about to go into the background as a result of user choice.
    description: |
        See also:
        [onPause](http://developer.android.com/reference/android/app/Activity.html#onUserLeaveHint())
        in the Android Developer Reference.
    since: "3.2.0"


properties:

  - name: actionBar
    summary: The action bar for this activity.
    description: |
        See also: [Action Bar](http://developer.android.com/guide/topics/ui/actionbar.html) in
        the Android Developer Reference.
    type: Titanium.Android.ActionBar
    permission: read-only

  - name: intent
    summary: The `Intent` that was used to start this Activity.
    type: Titanium.Android.Intent
    permission: read-only

  - name: onCreate
    summary: |
        Callback function called when the Android activity is created.
    since: "3.4.0"
    type: Callback<Object>

  - name: onCreateOptionsMenu
    summary: |
        Callback function called to initially create an Android options menu
        for this Activity when the user presses the **Menu** button.
    description: |
         See the menu examples in <Titanium.Android.Menu>.

         See also: 
         [Creating an Options Menu](http://developer.android.com/guide/topics/ui/menus.html#options-menu) 
         in the Android Developer's Guide.
    type: Callback<Object>

  - name: onDestroy
    summary: |
        Callback function called when the Android activity is destroyed.
    since: "3.4.0"
    type: Callback<Object>

  - name: onPause
    summary: |
        Callback function called when the Android activity is paused.
    since: "3.4.0"
    type: Callback<Object>

  - name: onPrepareOptionsMenu
    summary:  |
        Callback function called to prepare an options menu for display when the user presses
        the **Menu** button. 
    description: |
         See the menu examples in <Titanium.Android.Menu>.

         See also: 
         [Creating an Options Menu](http://developer.android.com/guide/topics/ui/menus.html#options-menu) 
         in the Android Developer's Guide.
    type: Callback<Object>

  - name: onRestart
    summary: |
        Callback function called when the Android activity is restarted.
    since: "3.4.0"
    type: Callback<Object>

  - name: onResume
    summary: |
        Callback function called when the Android activity is resumed.
    since: "3.4.0"
    type: Callback<Object>

  - name: onStart
    summary: |
        Callback function called when the Android activity is started.
    since: "3.4.0"
    type: Callback<Object>

  - name: onStop
    summary: |
        Callback function called when the Android activity is stopped.
    since: "3.4.0"
    type: Callback<Object>

  - name: requestedOrientation
    summary: Specifies a specific orientation for this activity.
    constants: Titanium.Android.SCREEN_ORIENTATION_*
    type: Number
    permission: write-only

examples:
  - title: Callback Example
    example: |
        The following example shows how to start an activity and retrieve a result code
        and optional data intent when the activity ends.
        
            activity.startActivityForResult(intent, function(e) {
                // The request code used to start this Activity
                var requestCode = e.requestCode;
                // The result code returned from the activity 
                // (http://developer.android.com/reference/android/app/Activity.html#StartingActivities)
                var resultCode = e.resultCode;
                // A Titanium.Android.Intent filled with data returned from the Activity
                var intent = e.intent;
                // The Activity the received the result
                var source = e.source;
            });
        
---
name: ActivityResult
summary: |
    Simple object passed to the
    [startActivityForResult](Titanium.Android.Activity.startActivityForResult) callback.
properties:

  - name: requestCode
    summary: |
        Unique, automatically generated integer request code.
    type: Number

  - name: resultCode
    summary: |
        Integer result code that the started activity passed to
        [setResult](Titanium.Android.Activity.setResult).
    type: Number

  - name: intent
    summary: |
        Intent that can contain data returned to the caller. Data can be attached to
        the intent as "extras").
    type: Titanium.Android.Intent


{'fraction_non_alphanumeric': 0.07863815208372367, 'fraction_numerical': 0.004014881828644843, 'mean_word_length': 2.802361082841441, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 38, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1540871', 'n_tokens_mistral': 9920, 'n_tokens_neox': 9466, 'n_words': 3661}