4

I have a website which should supposedly only using WebView in my app, otherwise my website redirects the user to a page from where he can download my App.

So, how can I change this UA in WebView?

Also, what are the possible issues which can arise from this?

Ayush Gupta
  • 8,716
  • 8
  • 59
  • 92
  • 1
    Did you try [`myWebView.getSettings().setUserAgentString("custom user agent")`](https://stackoverflow.com/a/47166980/1518921)? – Protomen Nov 10 '17 at 15:54

2 Answers2

5

You can use setUserAgent from android.webkit.WebSettings, simple example:

WebView myWebView = (WebView) findViewById(R.id.myWebView);

WebSettings myWebSettings = myWebView.getSettings();
myWebSettings.setUserAgentString("Foo/Bar"); # Set your custom user-agent

Also, what are the possible issues which can arise from this?

Depends on what you did, userAgent is not "perfect", but was created for this purpose, identify the browser.

Protomen
  • 9,471
  • 9
  • 57
  • 124
0

You can send any POST parameter to your website in your app. Otherwise your website can determines that is calling from other browsers. Here is a sample may help you.

Community
  • 1
  • 1
Ahmad Behzadi
  • 1,006
  • 15
  • 30