You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Joe Bowser (JIRA)" <ji...@apache.org> on 2015/12/09 01:21:11 UTC

[jira] [Commented] (CB-9570) CordovaPlugin lifecycle differs from Activity lifecycle

    [ https://issues.apache.org/jira/browse/CB-9570?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15047757#comment-15047757 ] 

Joe Bowser commented on CB-9570:
--------------------------------

No, this doesn't make sense and here is why:

The code responsible for the plugins running the onStart and onResume is here:
{code}
    /**
     * Called when the activity is becoming visible to the user.
     */
    public void onStart() {
        for (CordovaPlugin plugin : this.pluginMap.values()) {
            if (plugin != null) {
                plugin.onStart();
            }
        }

 /**
     * Called when the activity will start interacting with the user.
     *
     * @param multitasking      Flag indicating if multitasking is turned on for app
     */
    public void onResume(boolean multitasking) {
        for (CordovaPlugin plugin : this.pluginMap.values()) {
            if (plugin != null) {
                plugin.onResume(multitasking);
            }
        }
    }
{code}

This code has a null check, because by default the plugins aren't actually loaded until they're called.  This means that you can have the plugins installed, but the plugins aren't actually loaded into memory until you actually invoke a plugin for the first time.  Of course, if you set the plugin to load at the start, then this will be called.  This needs to be documented better, BUT the plugins don't differ that greatly from the activity lifecycle, they just don't get loaded until they are needed, unless you explicitly set them to be.



> CordovaPlugin lifecycle differs from Activity lifecycle
> -------------------------------------------------------
>
>                 Key: CB-9570
>                 URL: https://issues.apache.org/jira/browse/CB-9570
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 3.5.0
>            Reporter: Kai Schlamp
>            Assignee: Joe Bowser
>
> The CordovaPlugin has the same onStart and onResume callback methods as Androids Activity class. Unfortunately those differ from the Activity Lifecycle (see http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle).
> The onStart and onResume methods of CordovaPlugin are not called when the app starts for the first time (in contrast to the appropriate Activitiy methods).
> Wouldn't it make sense to have the same lifecycle as an Activity (which is quite right in my opinion)?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org