Here, I will give you the source codes to convert your Website into a professional-looking Android Application. I separate the codes step by step as we need them.
Step 1:
Copy and Paste this copy in the AndroidManifest.xml [ After the third line (package="com.example.demo">)]
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
Step 2:
Copy and paste this in webview.
android:id="@+id/webview
Step 3:
Now go to MainActivity.java and click on import. after that copy and paste this code below the (import android.os.Bundle;)
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
Step 4:
Now copy and paste this code under ( public class MainActivity extends AppCompatActivity { )
private WebView mywebView;
Step 5:
Now Copy and paste this code under ( setContentView(R.layout.activity_main); )
mywebView=(WebView) findViewById(R.id.webview);
mywebView.setWebViewClient(new WebViewClient());
mywebView.loadUrl("https://codewati.blogspot.com/");
WebSettings webSettings=mywebView.getSettings();
webSettings.setJavaScriptEnabled(true);
Step 6:
And the last Copy and paste this code after the close curly bracket
public class mywebClient extends WebViewClient{
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon){
super.onPageStarted(view,url,favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view,String url){
view.loadUrl(url);
return true;
}
}
@Override
public void onBackPressed(){
if(mywebView.canGoBack()) {
mywebView.goBack();
}
else{
super.onBackPressed();
}
}
For more check out our Youtube Channel "Codewati"
👇🏻Video Tutorial for this Post👇🏻
Comments