Convert Website Into An Android App | #2 Make your first simple webview app

 1. เคจिเคšे เคฆिเค เคนुเค Code เค•ो  Activity_Main.xml  เคฎें  Image เคฎें เคฆिเค–ाเค เคนुเค เคธ्เคฅाเคจ เคชเคฐ paste เค•เคฐे!

<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
tools:ignore="MissingConstraints" />



2. เค…เคฌ เคจिเคšे เคฆिเค เคนुเค Code เค•ो  MainActivity.java  เคฎें  Image เคฎें เคฆिเค–ाเค เค…เคจुเคธाเคฐ Package Name เค•ो เค›ोเฅœเค•เคฐ เคฌाเค•ी Code เค•े เคธ्เคฅाเคจ เคชเคฐ Paste เค•เคฐें!

import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

String websiteURL = "https://YouTube.com/technicalsangrah"; // sets web url
private WebView webview;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

//Webview stuff
webview = findViewById(R.id.webView);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setDomStorageEnabled(true);
webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER);
webview.loadUrl(websiteURL);
webview.setWebViewClient(new WebViewClientDemo());

}

private class WebViewClientDemo extends WebViewClient {
@Override
//Keep webview in app when clicking links
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}

}





3. เค…เค—เคฐ เค†เคชเค•े เคฎें เค•ोเคˆ Error เค†เคคा เคนै เคคो เคจिเคšे เคฎें เคฆिเค–ाเค เค…เคจुเคธाเคฐ เค…เคชเคจे Mouse pointer เค•ो เคตเคนां เคชเคฐ เคฒे เคœाเค‡เค เคซिเคฐ เค‰เคธเค•ो Solve เค•เคฐเคจे เค•ा Option Android studio เคฎें show เคนोเคจे เคฒเค—เคคा เคนै เค‰เคธे เค†เคช Click เค•เคฐเค•े เคฆेเค– เคธเค•เคคे เคนै เค…เค—เคฐ work เคจเคนीं เค•เคฐเคคा เคนै เคคो เค†เคช Undo "Ctrl+Z" เค•เคฐ เคธเค•เคคे เคนैं!




3. เคซिเคฐ เคจिเคšे เคฆिเค–ाเค เค—เค เคธ्เคฅाเคจ เคชเคฐ เค…เคชเคจे Website เค•ा Url เคกाเคฒें!




# เค…เคญी เค†เคชเค•े app เค•ो internet use เค•ा permission เคจเคนीं เคฎिเคฒा เคนै

4. Internat permission เค•े เคฒिเค เคจिเคšे เคฆिเค เคนुเค code เค•ो AndroidManifest.xml  (Go to app > manifests > AndroidManifest.xml )  เคฎें image เคฎें เคฆिเค–ाเค เค…เคจुเคธाเคฐ Paste เค•เคฐें!

<uses-permission android:name="android.permission.INTERNET" />




# เค…เคฌ เคฎेเคฐा Code เค‡เคธ เคคเคฐเคน (เคจिเคšे เคฆिเค–ाเคฏा เค—เคฏा เคนै) เคฆिเค–ाเคˆ เคฆे เคฐเคนा เคนै!



# เค…เคฌ เค†เคช เค…เคชเคจे app เค•ो Mobile เคธे Connect เค•เคฐเค•े เคฆेเค– เคธเค•เคคे เคนैं!

Comments

Popular posts from this blog

Convert Website Into An Android App | #10 Set Up Push Notifications

Convert Website Into An Android App | #6 Add Swipe down to Refresh functionality

Convert Website Into An Android App | #8 Adding a Splash Screen