Reputation: 171
I am making my first android app, it's a basic webview app which the app loads a url. This url is mobile optimized for any mobile phone to use it. However, the mobile version (not the app version) I created a MENU on the top right which basically drops down a div when clicked, works nice.
However, for users that will be using my android mobile version, I would really like the menu div be completely hidden and use android's in app menu. Is there a way to know if a user is using the android app versus a regular user using their native browser? Can I do this from the user-agent? Or would it show the same for both?
Upvotes: 0
Views: 617
Reputation: 7722
You could just set the user agent string inside your app to something easily recognizable like this:
webView.getSettings().setUserAgentString("my_funky_webapp")
Now you can be sure, it's your app that accesses your service.
Upvotes: 3
Reputation: 9933
You certainly can use the UserAgent string at the server, or send info in the URL. You can also bind JavaScript functions to objects in your app, so that, for example, you could have an object that is unique to your Android app, and if your JS code can find it, then you know you're on Android.
Upvotes: 0
Reputation: 2425
You could append ?androidapp=1 to the end of every URL in the WebView then detect this in your webpage
Upvotes: 0