5

I am creating a webapp and the user could only have acces with the android webview? Can i detect android webview with javascript?

2

3 Answers 3

4

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.

Sign up to request clarification or add additional context in comments.

Comments

3
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'; } 

Source : http://davidwalsh.name/detect-android

3 Comments

browser-apps would also detected which don't using the webview
it'll also detect android browsers, question is to detect if website is running inside webview through js.
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/…
2

Why not add a secret param that you will set every time you need it?

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.