[
https://issues.apache.org/jira/browse/CB-8684?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14482504#comment-14482504
]
Tony Homer edited comment on CB-8684 at 4/7/15 4:23 AM:
--------------------------------------------------------
[~agrieve] - I made [a rough cut of these
changes|https://github.com/tony--/cordova-android/commit/be04785f2ce8cbf3f2f96398641af270db12b76c].
The next step I planned to do was to run the existing tests, then add some
new tests to cover my handy dandy new onStart/onStop event dispatching.
Unfortunately I can't figure out how to make the tests work. I saw [the
warning in the
README.md|https://github.com/apache/cordova-android/blame/master/test/README.md#L24],
but I thought maybe I could make them work in kitkat+ since it seemed like it
might have to do with the thread rules for the webview in kitkat+. I followed
the instructions for setting up gradle, ran the test app and got an error about
the Activity plugin not being found. This doesn't seem kitkat related - it
just seems like the plugin is not present in cordova_plugins.js, so is not
getting initialized. Are there some missing instructions or am I completely
missing something? I'll keep looking on my own, but any pointers would be
helpful! I'll also send a message to the dev list if I don't hear back in the
next day or so. Thanks in advance!
Update: I just realized that I only tried to run the manual tests
(installDebug). I just tried running the unit tests (connectedAndroidTest) and
something happened, possibly good? I'm not sure how to see the test results,
but I'll keep looking.
Update 2: Does "BUILD SUCCESSFUL" mean that the tests all passed? I guess I
can modify some of the tests to force a failure and see if that makes it say
"BUILD FAIL". Sorry I am a noob that is spamming your inbox.
was (Author: tony--):
[~agrieve] - I made [a rough cut of these
changes|https://github.com/tony--/cordova-android/commit/be04785f2ce8cbf3f2f96398641af270db12b76c].
The next step I planned to do was to run the existing tests, then add some
new tests to cover my handy dandy new onStart/onStop event dispatching.
Unfortunately I can't figure out how to make the tests work. I saw [the
warning in the
README.md|https://github.com/apache/cordova-android/blame/master/test/README.md#L24],
but I thought maybe I could make them work in kitkat+ since it seemed like it
might have to do with the thread rules for the webview in kitkat+. I followed
the instructions for setting up gradle, ran the test app and got an error about
the Activity plugin not being found. This doesn't seem kitkat related - it
just seems like the plugin is not present in cordova_plugins.js, so is not
getting initialized. Are there some missing instructions or am I completely
missing something? I'll keep looking on my own, but any pointers would be
helpful! I'll also send a message to the dev list if I don't hear back in the
next day or so. Thanks in advance!
Update: I just realized that I only tried to run the manual tests
(installDebug). I just tried running the unit tests (connectedAndroidTest) and
something happened, possibly good? I'm not sure how to see the test results,
but I'll keep looking.
> support onStart/onStop lifecycle events in plugins for Android
> --------------------------------------------------------------
>
> Key: CB-8684
> URL: https://issues.apache.org/jira/browse/CB-8684
> Project: Apache Cordova
> Issue Type: Improvement
> Components: Android
> Reporter: Tony Homer
> Assignee: Tony Homer
>
> Enable plugins to handle onStart/onStop lifecycle events in Android
> implementation. Currently plugin authors that need this feature instruct
> their users to modify the CordovaActivity in their project in order to
> support these lifecycle events.
> For example, the Flurry plugin instructions direct users to override
> onStart and onStop in their activity in order to handle onStop:
> https://github.com/Initsogar/cordova-flurry
> There are other analytics plugins that want to know about onStart/onStop
> instead of onPause/onResume.
> This change will enable native Android support only - there will be no
> corresponding Cordova lifecycle events generated because these events are
> platform specific.
> In addition to the Android platform change, a "quirk"-type notation should be
> added to the Android Plugin Development guide, along with possible update to
> the example code provided there.
> For reference, here is the conversation from the dev mailing list between
> [~agrieve] and [~tony--]:
> {quote}
> On 3/9/15, 12:05 PM, "Andrew Grieve" <[email protected]> wrote:
> >I see no reason we couldn't add onStart / onStop.
> >
> >As an aside, if you're okay with supporting only ICS+, you can use
> >Application.registerActivityLifecycleCallbacks() as a work-around.
> >
> >
> >On Mon, Mar 9, 2015 at 11:23 AM, Homer, Tony <[email protected]>
> wrote:
> >
> >> I assumed that this must have been discussed at some point, but I
> >>couldn¹t
> >> find anything in the list archives or JIRA.
> >> I¹m guessing that there might be some practical issues with
> >>onStart/onStop
> >> and plugin loading timing, but it seems like if there are issues like
> >>this
> >> they could be addressed somehow.
> >>
> >> I¹m asking about this because we have an internal request to enable apps
> >> to override onStart/onStop in the Intel XDK build system in order to
> >> support plugins that want to handle onStart/onStop.
> >> My initial response was ³why not use onResume/onPause², but some plugin
> >> authors apparently believe that onStart/onStop are the lifecycle events
> >> they need.
> >>
> >> For example, the Flurry plugin instructions direct users to override
> >> onStart and onStop in their activity in order to handle onStop:
> >> https://github.com/Initsogar/cordova-flurry
> >> There are other analytics plugins that want to know about onStart/onStop
> >> instead of onPause/onResume.
> >> Obviously it is possible to modify your activity in order to do this in
> >> your project, but if this capability is important, it should be possible
> >> without abandoning the Cordova Way.
> >>
> >> So I was wondering what you guys think?
> >> onPause/onResume should be good enough for anyone?
> >> onStart/onStop are edge cases that users need to handle by modifying
> >>their
> >> activity?
> >> onStart/onStop cannot be handled by plugins due to timing issues?
> >>
> >> Thanks!
> >> Tony
> {quote}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]