Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7EFF110CCA for ; Fri, 14 Feb 2014 22:26:51 +0000 (UTC) Received: (qmail 6036 invoked by uid 500); 14 Feb 2014 22:26:50 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 5962 invoked by uid 500); 14 Feb 2014 22:26:50 -0000 Mailing-List: contact dev-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 dev@cordova.apache.org Received: (qmail 5953 invoked by uid 99); 14 Feb 2014 22:26:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Feb 2014 22:26:50 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of bowserj@gmail.com designates 209.85.128.174 as permitted sender) Received: from [209.85.128.174] (HELO mail-ve0-f174.google.com) (209.85.128.174) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Feb 2014 22:26:45 +0000 Received: by mail-ve0-f174.google.com with SMTP id pa12so10245332veb.33 for ; Fri, 14 Feb 2014 14:26:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=lYrpkoVE3ieKbiIAD7xN7/frn3ZFxM5pa9LYqxflhsI=; b=IONIBP+Y/sbuyWsg/OMM3Nj0FBq38r28HCkO693Drr81xIGsupX7x8sdpBc5sWImSt fIkTuKSYyi1h4DoirV5GJ1DYegIHSNoSrXxK2LBHhJMDqIRf4Ba9FZY05STstO0UXgxD lg5NAOE9l7zsQqXuy3yH3GiDdgKngEXvaSXrEaC7p7ETfLmGkLtjZWzrH+JixUsA1HnZ AImE3QeOUXL3llgp/NLU+PpYIjw3l8Gx7wvlYagGCrroC4PzFQbrUgrcBii6sNozQR44 ZXQ+m4KZeZwfNQdfsgzTJiP6rFObKvh/x8N42DoPO/tA5wc1olZ82Uus/iLH/Bi3cZNM iOTg== MIME-Version: 1.0 X-Received: by 10.52.168.39 with SMTP id zt7mr2363379vdb.42.1392416784286; Fri, 14 Feb 2014 14:26:24 -0800 (PST) Received: by 10.220.183.5 with HTTP; Fri, 14 Feb 2014 14:26:24 -0800 (PST) In-Reply-To: References: <9e8e3989cc8b59c641f3d16ff6566d66.squirrel@webmail2.colokoe.net> Date: Fri, 14 Feb 2014 14:26:24 -0800 Message-ID: Subject: Re: [Android] Apps restart instead of resume when brought to focus by clicking app icon From: Joe Bowser To: dev Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org On Fri, Feb 14, 2014 at 12:28 PM, Michal Mocny wrote: > Joe, I think you may have that backwards. singleTop means we don't get get > restarted so avoid the issue of preserving state. If we leave the > launchMode as the default, we *do* get killed off and lose state. Yeah, I did, which is why I changed my mind. :P We still should fix preserving state, and I'm not convinced that this is the right thing to do in all instances. > > Braden, if I understand what you say correct, singleTop is not good for > apps that have multiple activities which it launches conditionally > depending on incoming intent, but we do not so its a fine default? > We totally could have that, it depends on the plugin, which is why I propose that this be a config setting. > Bas, thanks for pointing that out. Seems they advise same default > launchMode. > > -Michal > > > On Fri, Feb 14, 2014 at 3:01 PM, Bas Bosman wrote: > >> Just wanted to point out a Pull Request on a Phonegap Build plugin related >> to this subject: >> https://github.com/phonegap-build/PushPlugin/pull/149 >> >> Don't have any expertise on the issue, but remembered reading this PR a >> few days ago. >> >> Bas >> >> > OK, I changed my mind after re-reading the docs once again. >> > >> > We should make this a configurable option ideally. singleTop might >> > make sense for legacy webview apps, but I'd have to see the way that >> > we do WebView. We still need to solve state preservation though. >> > >> > On Fri, Feb 14, 2014 at 11:20 AM, Joe Bowser wrote: >> >> Agreed. If we keep re-starting over and over again, we lose state. >> >> We haven't been successful in preserving the state of the app when we >> >> get killed off, so I think singleTop is a really terrible idea until >> >> we get state preservation solved, which is a really hard problem. >> >> >> >> On Fri, Feb 14, 2014 at 11:14 AM, Braden Shepherdson >> >> wrote: >> >>> I think singleTop is "not recommended" for typical Android apps, that >> >>> want >> >>> to go opening different activities using various Intents from >> >>> notifications. For something like Cordova, avoiding that restart is >> >>> ideal. >> >>> >> >>> Braden >> >>> >> >>> >> >>> On Fri, Feb 14, 2014 at 2:08 PM, Michal Mocny >> >>> wrote: >> >>> >> >>>> TLDR; AndroidManifest.xml needs: >> >>>> android:launchMode="singleTop" >> >>>> -- can I add it? >> >>>> >> >>>> Quick search brings up: >> >>>> >> >>>> >> http://stackoverflow.com/questions/10122449/phonegap-android-application-restarting-instead-of-resuming-although-it-was-not >> >>>> >> >>>> ..which advises to add android:launchMode="singleTask" to >> >>>> AndroidManifest.xml , which does fix the issue. >> >>>> >> >>>> According to the descriptions in >> >>>> >> http://developer.android.com/guide/topics/manifest/activity-element.htmlthe >> >>>> differences mostly stem in how the app handles intents, however, there >> >>>> is a comment in the table of descriptions which labels singleTask >> >>>> launchMode as "(not recommended for general use)". >> >>>> >> >>>> On the other hand, singleTop mode *is* recommended, and also fixes the >> >>>> issue, and according to the description, sounds to me like a much >> >>>> better >> >>>> default. >> >>>> >> >>>> So, does anyone have a reason to not set >> >>>> android:launchMode="singleTop" in >> >>>> the default cordova-android platform template? >> >>>> >> >>>> I notice Simon commented on the above SO question, so I guess we were >> >>>> already aware of the issue a while ago. Is there a conscious reason >> >>>> for >> >>>> not setting that launchMode by default, or did this just slip through >> >>>> the >> >>>> cracks? Is there a known downside? >> >>>> >> >>>> -Michal >> >>>> >> > >> >> >>