Thursday, December 22, 2011

HTML5 history support in mobile browsers

For those of you who don`t know theres a new HTML5 API out there for handling the browsers history. (eg. what happens when the user presses back, or reloads the page)

It provides the following functions:

  • change the current history entry (replaceState)
  • add a new history entry onto the stack (pushState)
  • receive an event if the stack has changed(user pressing forward or back)
  • Get the size of the history stack
  • go forward and backwards in history
Together this set of apis provides a nice way to handle the android back button inside a web application. You can actually mimic the behavior of a native app with the back button, as long as android supports the html5 history api.

I was very pleased to see support for this in android 2.2 and android 2.3, but was kind of worried to see that this was not working properly in android 3.x. But I wasn't too worried, because android 3.x was rushed to get out the door and never really had that much devices ( see:

When I installed android 4.0 last week on my phone I was very surprised to see that mgwt used a fallback mechanism (introduced for the few android 3.x devices) to get the back button working. So I did some digging and was able to find out that that android 4.0 does not support html5 history api.

Why is HTML5 history support important?
If you want to use the back button properly with your android web app, you need to get an event when the user presses that back button. If the browser does not support the html5 history api you can still get an event by using a hashtag mechanism in the url (like GWT has done for quite a long time), but you will not be able to change the current entry on the history stack. So you will get inconsistencies when trying to mimic the behavior of the android activity stack.
The second thing is performance: It seems that the history pop event fires immediately, while the hashtag mechanism needs on my phone at least one second before the gwt app sees the action. This leeds to a serious sluggish feeling when using the back button. I haven't had the time to look into this maybe there is something that can be done about it.

There is a discussion in the gwt contributer group ( that discusses if we can implement a history replace mechanism on top of the hash tag mechanism so there might be a way to get some decent behavior in web apps inside android 4. 

This leaves me wondering what google is doing with android and why it is so hard for them to have a matching browser to apples mobile safari. This is working properly on android 2.2 and 2.3, why is it not working in android 4?

Also there wasn't any issue on the android tracker regarding this. I will be doing some more research and post a bug report eventually, so that we can get this fixed some time in the future... 
Someone else already file a bug (see

Also I will try to find a way to get the best possible current solution for mgwt web apps (note: with gwt-phonegap you can get a direct event if the user presses the back button).


  1. This comment has been removed by the author.

  2. I am happy to find this post very useful for me, as it contains lot of information. I always prefer to read the quality content and this thing I found in you post. Thanks for sharing. Search Bar Firefox 57 Quantum addon

  3. رش مبيدات بالمدينة المنورة رش مبيدات بالمدينة المنورة
    رش مبيدات بالدمام رش مبيدات بالدمام
    مكافحة الحمام بالمدينة المنورة مكافحة الحمام بالمدينة المنورة

    غسيل خزانات بمكة غسيل خزانات بمكة
    غسيل خزانات بجدة غسيل خزانات بجدة
    غسيل خزانات بالدمام غسيل خزانات بالدمام

  4. This is a good post. This post gives truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. Thank you so much. Keep up the good works. como baixar HappyMod download 2020

  5. Thanks for every other informative site. The place else may just I get that kind of information written in such an ideal means? I have a venture that I’m just now operating on, and I have been on the look out for such information. aprenda como baixar Lucky Patcher apk

  6. Titanium Backup Apk is one of the most potent backup tools that restores the files of Android devices. Titanium Backup Alternative is the rooted Android.

  7. WhatsApp Group Links
    I have read a few of the articles on your website now, and I really like your style.
    WhatsApp Group Links

  8. As soon as we’re absolutely clear we’ll start the proofing procedure. Just about all evidence are sent by way of email till you’re 100% satisfied

  9. You've supplied us with an interesting article. This is a fantastic resource for expanding your understanding of the subject hire someone to write a paper. Thank you very much.

  10. Business travelers and regular globetrotters might benefit from a "No Steering SIM Card." For individuals who use their phones for business and communication, staying connected without changing SIM cards or dealing with convoluted roaming costs is a game-changer. This technology's development and impact on the worldwide mobile connection will be intriguing.