46

I want to run my Web App, which i programmed with HTML5, in fullscreen mode on Android. (hide the status bar, and the adress/navigation bar)

for iOS you only write:

<meta name="apple-mobile-web-app-capable" content="yes" /> 
<meta name="viewport" content="width=device-width, initial-scale=1.0">

But that did not work on Android.

There are a lot of solution´s with Javascript, but all solutions which I tried are inoperative.

Somebody know the solution?

user959456
  • 565
  • 1
  • 9
  • 13

8 Answers8

51

This worked for me on Chrome for Android.

Add this to the head tags:

<meta name="mobile-web-app-capable" content="yes">

Then in the chrome browser menu, Goto Add to Homepage. This Icon will now open your website up in fullscreen.

jason
  • 1,132
  • 14
  • 32
10

I use a mix of the HTML meta tag for iOS and a JavaScript solution. It takes away the address bar on iOS and android devices. It does not take out the bottom bar on iOS as this will only disappear when the user installs the web page as a HTML5 app on his home screen.

<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<script type='text/javascript' charset='utf-8'>
    // Hides mobile browser's address bar when page is done loading.
      window.addEventListener('load', function(e) {
        setTimeout(function() { window.scrollTo(0, 1); }, 1);
      }, false);
</script>

I use PHP in the backend to only render the JavaScript for mobile browser with the following mobile browser detection

if (preg_match('/iphone|ipod|android/',strtolower($_SERVER['HTTP_USER_AGENT'])))
philipp
  • 4,133
  • 1
  • 36
  • 35
3

You can achieve this with googles new progressive web app adding the service worker. Have a look here: https://addyosmani.com/blog/getting-started-with-progressive-web-apps/ and https://developers.google.com/web/progressive-web-apps/ .

You can add icon in homescreen for your webapp,get fullscreen, can use push notification etc.

crystalthinker
  • 1,200
  • 15
  • 30
3

I do not think you will find a global solution for that since not everybody uses the default android webbrowser (e.g. I prefer dolphin).

Facing that fact you will need to try every dirty javascript hack to force that behavior.

The only reason why this works for apple devices is the fact that apple is very restrictive about developing a custom browser and everybody sticks to the default app.

Code Lღver
  • 15,573
  • 16
  • 56
  • 75
Knickedi
  • 8,742
  • 3
  • 43
  • 45
1

As indicated by Google

Since Chrome M31, you can set up your web app to have an application shortcut icon added to a device's homescreen, and have the app launch in full-screen "app mode" using Chrome for Android’s "Add to homescreen" menu item.

See https://developer.chrome.com/multidevice/android/installtohomescreen

Alex Nolasco
  • 18,750
  • 9
  • 86
  • 81
1
<meta name="apple-mobile-web-app-capable" content="yes" /> 

This tag is designed to show a chromeless environment after you have added your site to the iPhone's home screen.

I wouldn't rely on this to work for android.

To make the browser bar scroll out of the way once your page has loaded see this question's answer: Removing address bar from browser (to view on Android)

Community
  • 1
  • 1
m6tt
  • 4,223
  • 1
  • 22
  • 20
  • 1
    This works perfectly in android, but I'd suggest to use a manifest (it gives more customization options) http://updates.html5rocks.com/2014/11/Support-for-installable-web-apps-with-webapp-manifest-in-chrome-38-for-Android – Luis Sieira Sep 19 '15 at 21:34
-8

From the Android side and for versions lower than honeycomb, this should be done using:

Window w = getWindow();
w.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
w.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

If the Android Browser doesn't do something like that when it reads the meta info, I would try looking into phonegap to check if they solve this issue.

Macarse
  • 91,829
  • 44
  • 175
  • 230
  • 5
    It is an WEB-App (HTML5) Not a Native App – user959456 Sep 22 '11 at 15:47
  • @user959456: Plz, read my complete answer. That lines are what the browser should do when the metadata is read. If the default browser is not doing that I recommend you to check is phonegap solved this. – Macarse Sep 22 '11 at 16:22
-8

This code might help...

public void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE); --> hide the Top Android Bar.
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
wattostudios
  • 8,666
  • 13
  • 43
  • 57
user1251064
  • 35
  • 10
  • 2
    See the post below, its not about a native app! – theomega Mar 25 '12 at 21:30
  • 1
    @user1.251064 although the downvotes suggest unpopularity, they don't give any clue as to why ...so: Maybe there's confusion between "web app" (runs in the browser) and "native app" (usually obtained from the app store). Web Apps use HTML/HTML5 and CSS and Javascript ...but not any form of Java (at least not 99% of the time:-). Web Apps do not have direct access to the native SDK. A good rule of thumb is if it's in Java, it's relevant only to native apps not to web apps. – Chuck Kollars Apr 26 '13 at 20:50