Answer the question
In order to leave comments, you need to log in
How to send a site that I'm not from a smartphone in WebView?
Good day, playing around with WebView, creating a mini-browser for myself. I need to visit the site through my browser "as if" from a computer, and not from a mobile device (so that it does not redirect to the mobile version). Can you please tell me how to send headers to the site that I came from the computer using WebView? This is how I implement WebView
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
private WebView mWebView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.webView);
mWebView.getSettings().setJavaScriptEnabled(true); // Включай JS
mWebView.setWebViewClient(new MyWebViewClient());
mWebView.loadUrl("https://yandex.ru");
}
}
class MyWebViewClient extends WebViewClient
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question