Android Webview in Desktop Mode in Android Studio FREE Source Code
Hi there,
In this Blogpost,
I am going to give the Complete Source Code for loading the WebView website in Desktop mode in Android Studio. This is working fine. You can watch the Android Tutorials Youtube Channel Video to see the Implementation of this Android WebView in Desktop Mode. The Video and Source Code is given below.
Android Webview in Desktop Mode in Android Studio FREE Source Code
Here is the Desktop Mode WebView Source Codes:
// Source Code Starts//
package webview.demo;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
public class MainActivity extends AppCompatActivity {
WebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String webpage = "https://www.fiverr.com";
webView = findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.loadUrl(webpage);
String userAgent = webView.getSettings().getUserAgentString();
try {
String androidString = webView.getSettings().getUserAgentString().
substring(userAgent.indexOf("("),userAgent.indexOf(")")+ 1);
userAgent = webView.getSettings().getUserAgentString().replace(androidString,"X11; Linux x86_64");
}catch (Exception e){
e.printStackTrace();
}
webView.getSettings().setUserAgentString(userAgent);
webView.reload();
}
}
// Source Code Ends//
GitHub Gist:
And If you Got the Result from Android Webview in Desktop Mode in Android Studio FREE Source Code then You Subscribe to Android Tutorials Youtube Channel and for any Query feel free to comment I will respond to you as soon as possible.
SUBSCRIBE HERE
(1) How To Convert A Website Into a Professional Android App Using ANDROID STUDIO 2020 - https://www.youtube.com/playlist?list=PL7nYsbTdViSqf_RlSZvdMshSxCdeE7Dl6
(2) Wallpaper App in Android Studio (using Pexel API) | Android Tutorials - https://www.youtube.com/playlist?list=PL7nYsbTdViSowlrgM6rDQJrIL7lL2ansh
(3) IMAGE TO TEXT APP IN ANDROID STUDIO - https://www.youtube.com/playlist?list=PL7nYsbTdViSqwJH3FsSYAsfUaEaadrTfv
(4) Quotes App in Android Studio - https://www.youtube.com/playlist?list=PL7nYsbTdViSquxqbF6uu3mD5q8K9fmw0V
It works!
ردحذفI have checked lot of answers in stackoverflow but none of them worked for me.
finally I found this solution , thanks a lot.
Bro Not working this code plase update
ردحذفإرسال تعليق