Search code examples
androidwebviewuser-agentandroid-sdk-tools

Is it possible to detect a user is from android app?


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?


Solution

  • 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.