How to View a PC in WebView

Asked 2 years ago, Updated 2 years ago, 80 views

I am a beginner in Android development.
I don't know how to display my PC in WebView.
Changing the UserAgent was a hit, but I don't know how to do it.

LayoutInflater factory=LayoutInflater.from(this);
View inputView=factory.inflate(R.layout.wiki_job_dialog, null);

WebView webView 1= (WebView) inputView.findViewById (R.id.webView1);
webView 1.setWebViewClient(newWebViewClient(){
    @ Override
    public boolean shouldOverrideUrlLoading (WebView view, String url) {
        return false;
    }
});
webView1.loadUrl("http://seesaawiki.jp/rgbyserver/d/Job%B0%EC%CD%F7%B5%DA%A4%D3%C7%BD%CE%CF%C0%E2%CC%C0%A1%AA");
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setView(inputView);

builder.setPositiveButton("OK", newDialogInterface.OnClickListener(){
    @ Override
    public void onClick (DialogInterface dialog, int whichButton) {
    }
});
AlertDialog dialog = builder.create();
dialog.show();

Also, instead of a browser, you can view one site.

android webview

2022-09-30 19:21

1 Answers

The user agent can be retrieved and configured with the following code:

webView1.getSetting().getUserAgentString();// Retrieves
webView1.getSetting().setUserAgentString();// Settings

I think it is possible to display the PC version of the page by setting up the user agent used by the PC browser.
Regarding the description of the user agent, I think the following site will be useful.
userAgent List/User Agent List


2022-09-30 19:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.