본문 바로가기
이과/웹앱

Web app 그냥 만들기_2

by 코딩초밥 2022. 4. 3.
반응형

1. 안드로이드

 

https://developer.android.com/studio?gclid=CjwKCAjwxZqSBhAHEiwASr9n9ABqD9a0n2SBxl-ZKg0M2Jb2p9Fh5bu8LqdFYk82NB3-J_KRG4Al8BoCOQEQAvD_BwE&gclsrc=aw.ds 

 

Download Android Studio and SDK tools  |  Android Developers

The official IDE for Android app developers.

developer.android.com

설치가되셨다면. 

 

 

MainActivity.java (아직 닷홈주소가없으시다면 공백으로 납두세용 이후에 채우시면됩니다


import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;

import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import java.net.URISyntaxException;

public class MainActivity extends AppCompatActivity {
    private WebView wv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        wv = findViewById(R.id.wv);
        wv.loadUrl("자신의 닷홈 주소.");
        WebSettings webSettings = wv.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setSupportMultipleWindows(false);
        webSettings.setJavaScriptCanOpenWindowsAutomatically(false);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setUseWideViewPort(true);
        webSettings.setSupportZoom(false);
        webSettings.setBuiltInZoomControls(false);
        webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        webSettings.setDomStorageEnabled(true);


    }
    public void onBackPressed() {
        if (wv.canGoBack()) {
            wv.goBack();
        } else {
            super.onBackPressed();
        }

    }

}

짧은설명

webview 세팅하는것입니다. 기본 세팅값들이니 복붙해주시면됩니다.

WebSettings webSettings = wv.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportMultipleWindows(false);
webSettings.setJavaScriptCanOpenWindowsAutomatically(false);
webSettings.setLoadWithOverviewMode(true);
webSettings.setUseWideViewPort(true);
webSettings.setSupportZoom(false);
webSettings.setBuiltInZoomControls(false);

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <WebView
        android:id="@+id/wv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>

짧은설명

웹뷰로만 화면 가득채울려고 넣었습니다.

반응형

'이과 > 웹앱' 카테고리의 다른 글

Uncaught SyntaxError: Unexpected token '<'  (2) 2022.04.14
[ajax]js파일에서 php안될때 해결 XMLHttpRequest  (3) 2022.04.13
Web app 그냥 만들기_4  (1) 2022.04.08
Web app 그냥 만들기_3  (1) 2022.04.05
Web app 그냥 만들기  (3) 2022.04.02

댓글