Return-Path: X-Original-To: apmail-cordova-issues-archive@minotaur.apache.org Delivered-To: apmail-cordova-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C9C65111B1 for ; Thu, 24 Apr 2014 15:46:20 +0000 (UTC) Received: (qmail 2311 invoked by uid 500); 24 Apr 2014 15:46:18 -0000 Delivered-To: apmail-cordova-issues-archive@cordova.apache.org Received: (qmail 2258 invoked by uid 500); 24 Apr 2014 15:46:17 -0000 Mailing-List: contact issues-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list issues@cordova.apache.org Received: (qmail 2217 invoked by uid 99); 24 Apr 2014 15:46:16 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Apr 2014 15:46:16 +0000 Date: Thu, 24 Apr 2014 15:46:16 +0000 (UTC) From: =?utf-8?Q?Mikael_St=C3=A5ldal_=28JIRA=29?= To: issues@cordova.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CB-6391) Should be possible to intercept exiting of web app MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-6391?page=3Dcom.atlassian.ji= ra.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1397985= 4#comment-13979854 ]=20 Mikael St=C3=A5ldal commented on CB-6391: ------------------------------------ I have signed and submitted the CLA now. > Should be possible to intercept exiting of web app > -------------------------------------------------- > > Key: CB-6391 > URL: https://issues.apache.org/jira/browse/CB-6391 > Project: Apache Cordova > Issue Type: Improvement > Components: Android > Affects Versions: 3.4.0 > Environment: Android > Reporter: Mikael St=C3=A5ldal > Assignee: Andrew Grieve > Labels: android, webview > > I am integrating Cordova into an existing Android app, using CordovaWebVi= ew. > When the web app exits (due to pressing back button beyond history), the = CordovaWebView invokes finish() on the Activity. This is not always what yo= u want. If you use Fragments, you might want to swap fragments rather than = exit the Activity. > Here is a patch to fix this (based on 3.4.0): > {noformat} > diff --git a/org/apache/cordova/CordovaActivity.java b/org/apache/cordova= /CordovaActivity.java > index 9f8b020..a6d3502 100755 > --- a/org/apache/cordova/CordovaActivity.java > +++ b/org/apache/cordova/CordovaActivity.java > @@ -829,6 +829,7 @@ public class CordovaActivity extends Activity impleme= nts CordovaInterface { > } > } > =20 > + @Override > /** > * End this activity by calling finish for activity > */ > diff --git a/org/apache/cordova/CordovaInterface.java b/org/apache/cordov= a/CordovaInterface.java > index 59ed486..262d7ca 100755 > --- a/org/apache/cordova/CordovaInterface.java > +++ b/org/apache/cordova/CordovaInterface.java > @@ -69,4 +69,11 @@ public interface CordovaInterface { > * Returns a shared thread pool that can be used for background task= s. > */ > public ExecutorService getThreadPool(); > + > + /** > + * Called when the web app exits. > + * Normally, you would just call {@link android.app.Activity#finish(= )}, > + * but a sophisticated application might want to do something else l= ike swapping fragments. > + */ > + public void endActivity(); > } > diff --git a/org/apache/cordova/CordovaWebView.java b/org/apache/cordova/= CordovaWebView.java > index 4dfeb55..28e9561 100755 > --- a/org/apache/cordova/CordovaWebView.java > +++ b/org/apache/cordova/CordovaWebView.java > @@ -760,7 +760,7 @@ public class CordovaWebView extends WebView { > //this.activityState =3D ACTIVITY_EXITING; > //return false; > // If they hit back button when app is initializi= ng, app should exit instead of hang until initi > - this.cordova.getActivity().finish(); > + this.cordova.endActivity(); > } > } > } > {noformat} -- This message was sent by Atlassian JIRA (v6.2#6252)