[ https://issues.apache.org/jira/browse/CB-8684?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14485942#comment-14485942 ]
ASF GitHub Bot commented on CB-8684: ------------------------------------ Github user tony-- commented on a diff in the pull request: https://github.com/apache/cordova-android/pull/173#discussion_r28009491 --- Diff: test/androidTest/src/org/apache/cordova/test/CordovaPluginTest.java --- @@ -0,0 +1,126 @@ + +package org.apache.cordova.test; + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +import android.app.Activity; +import android.test.ActivityInstrumentationTestCase2; + +import org.apache.cordova.CordovaWebView; + +import java.io.IOException; +import java.lang.reflect.Method; + +public class CordovaPluginTest extends ActivityInstrumentationTestCase2<LifeCyclePluginTestActivity> { + + public static String TAG = "CordovaPluginTest"; + protected LifeCyclePluginTestActivity testActivity; + protected LifeCyclePlugin testPlugin; + protected CordovaWebView cordovaWebView; + + @SuppressWarnings("deprecation") + public CordovaPluginTest() { + + super("org.apache.cordova.test", LifeCyclePluginTestActivity.class); + } + + protected void setUp() throws Exception { + super.setUp(); + testActivity = getActivity(); + cordovaWebView = testActivity.getCordovaWebView(); + testPlugin = (LifeCyclePlugin)cordovaWebView.getPluginManager().getPlugin("LifeCycle"); + } + + private void invokeBlockingCallToLifeCycleEvent(final String lifeCycleEventName) { + final CordovaPluginTest me = this; --- End diff -- Ok. > 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" <agri...@chromium.org> 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 <tony.ho...@intel.com> > 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: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org