I am creating a webapp and the user could only have acces with the android webview? Can i detect android webview with javascript?
3 Answers
From http://developer.android.com/guide/webapps/webview.html#EnablingJavaScript
For example, if you're developing a web application that's designed specifically for the WebView in your Android application, then you can define a custom user agent string with setUserAgentString(), then query the custom user agent in your web page to verify that the client requesting your web page is actually your Android application.
Comments
var ua = navigator.userAgent.toLowerCase(); var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile"); if(isAndroid) { // Do something! // Redirect to Android-site? window.location = 'http://android.davidwalsh.name'; } 3 Comments
Marvin Emil Brach
browser-apps would also detected which don't using the webview
Dr. DS
it'll also detect android browsers, question is to detect if website is running inside webview through js.
Steven
It's not the right answer it also detect browers like Firefox or Chrome as 'android' . This is the only thing that works: stackoverflow.com/questions/6783185/…