Wow reading this first would have saved me a many, many hours.

It's not just WebView apps, but can be as simple as Hello,World.  I
had a pretty complex app with intents in a tabhost that I thought was
the problem, whittled down to a simple tabhost app with Intents, down
to a tabhost with a view factory, whittled down to just hello world.

What I found was my app launch from eclipse would get onCreate, and
the usual flow.  Hitting the home key, then relaunching the app from
the android emulator launcher, would result in another onCreate call.
Repeat this pattern (home key, launch app), and when you get tired,
start hitting the back button in your app.
The prior app instances are shown instead of the launcher.
Until -- your app gets an onDelete(). Now it's ok.  Now when you tap
the icon from the launcher (onCreate), hit home, and hit the app icon
again, another onCreate is not sent -- it's working as normal --
hitting back button gets you to the launcher
>From now on, it works fine.  Subsequent launches are from the
launcher, and all is good.

Here's all you need to repro the problem: this code, eclipse, and the
plugin.
Build from eclipse, run it from eclipse, app launches.  Hit home, hit
the app icon, hit home, hit app icon.  Now hit the back button.
- expected is that you would exit back to the launcher
- what you get is a prior instance (I guess) of your app

public class MyTest extends Activity {
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.my_content);
  System.out.println("onCreate");
}



On Apr 9, 1:20 pm, UBZack <zferv...@gmail.com> wrote:
> Hi Mark, thank you very much for your reply.
>
> I have some more findings to report!  Turns out it's not just
> launching it from Eclipse that causes this behavior, but also
> downloading the apk from the Android web browser, installing it, and
> tapping the launch button.
>
> I set up a basic hello world app, uploaded it to my site, downloaded
> it on my G1, installed it, hit the Launch button after it said the
> install was successful, and it opened the app, showing the root
> activity.  I then hit the Home button, and re-opened the app.  It
> opened and showed the root activity, but then I hit the back button,
> and it showed the same root activity that was previously instantiated
> when it first launched.
>
> I have not tried this with downloading an app from the Android Market,
> but I would say that this is a bug in Android that should be fixed,
> specifically in its package installer, or perhaps just in launching an
> app in general right after installing it.  Anyway, thank you again for
> your contributions, and if you have anything else to add to my
> observations I'd be more than glad to hear it!
>
> Best,
> Zack
>
> On Apr 8, 6:44 pm, Mark Murphy <mmur...@commonsware.com> wrote:
>
> > UBZack wrote:
> > > I did a little poking around and I think I can DEFINITELY shine some
> > > light on this.
>
> > > Basically, I think the difference lies in the way Eclipse ports the
> > > apk to theemulatorand launches it.
>
> > <lengthy detailed analysis snipped>
>
> > > It seems that eclipse ports the app to theemulatorin such a way that
> > > each successive launch that is made while the app is running pushes
> > > another instance of the app onto the stack, unless you hit the back
> > > button before relaunching.
>
> > I don't use Eclipse. If I understand correctly, from this post and
> > others, is that when you run the application from Eclipse, you are taken
> > right to the initialactivityof that application, bypassing the home
> > screen and launcher.
>
> > In that case, what may be happening is that Eclipse tells theemulator
> > to launch the rootactivity...and specifies FLAG_ACTIVITY_NEW_TASK and
> >  FLAG_ACTIVITY_MULTIPLE_TASK on the launching Intent. That would provide
> > the behavior you're experiencing, if I understand correctly.
>
> > > Any light that you guys can shine on this would help a lot, and well
> > > done on providing very helpful examples and suggestions
>
> > Clearly, Eclipse is part of a broader Hulu-led initiative to "turn our
> > chunky brain matter into creamy goo". ;-)
>
> > > Mark, you've been quite a legend on this forum!
>
> > Legend? I hope not. Legends are frequently rather dead.
>
> > But, thanks!
>
> > --
> > Mark Murphy (a Commons 
> > Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> > Android App Developer Training:http://commonsware.com/training.html
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to