Android Studio-তে website to apps convert তৈরি করার জন্য আপনাকে XML এবং Java (বা Kotlin) কোড ব্যবহার করতে হবে। নিচে উদাহরণ দেওয়া হলো:
Today i share with you how to make an app for your website. Use this line code in your xml file Example - activity_main.xml Use this line code < RelativeLayout> Here your past the code < RelativeLayout />
XML
< WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Add the INTERNET permission to your manifest file. outside the application tag in your AndroidManifest.xml
Manifest
Java
< uses-permission android:name="android.permission.INTERNET" />
< uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Assign Variable :
Java
Java
WebView webView;
Just rearrange your code a bit as follows onCreate() Method :-
Java
webView = findViewById(R.id.webview);
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setDomStorageEnabled(true);
webSettings.setAllowContentAccess(true);
webView.loadUrl("YOUR WEBSITE URL");
Handling the Android Back Button
WebView has a method canGoBack which tells you if there is anything on the page stack that can be popped. All you need to do is detect a back button press and determine if you should step back through the WebView's history or allow the platform to determine the correct behaviour. Inside your MainActivity class, add the following method (in bold):
Java
@Override
public void onBackPressed() {
if(webView.canGoBack()) {
webView.goBack();
} else {
super.onBackPressed();
}
}

এরকম আরো পোস্ট চাই
ReplyDelete