본문 바로가기
개발 공부 Today I Learned

[국비 79일차 TIL] 안드로이드 기본 설정

by 개발자신입 2024. 3. 18.
반응형

안드로이드

수정할 파일

 

 

AndroidManifest.xml

uses-permission 코드 한 줄 추가 = internet 권한
android:usesCleartextTraffic="true" 추가

<?xml version="1.0" encoding="utf-8"?>  
<manifest xmlns:android="http://schemas.android.com/apk/res/android"  
    xmlns:tools="http://schemas.android.com/tools">  
    <uses-permission android:name="android.permission.INTERNET"/>  
  
    <application        android:allowBackup="true"  
        android:dataExtractionRules="@xml/data_extraction_rules"  
        android:fullBackupContent="@xml/backup_rules"  
        android:icon="@mipmap/ic_launcher"  
        android:label="@string/app_name"  
        android:roundIcon="@mipmap/ic_launcher_round"  
        android:supportsRtl="true"  
        android:theme="@style/Theme.Test"  
        android:usesCleartextTraffic="true"  
        tools:targetApi="31">  
        <activity android:name=".MainActivity" android:exported="true">  
            <intent-filter>                
            <action android:name="android.intent.action.MAIN" />  
            <category android:name="android.intent.category.LAUNCHER" />  
            </intent-filter>        
         </activity>    
     </application>  
</manifest>

activity_main.xml

androidx.constraintlayout.widget.ConstraintLayout => LinearLayout으로 변경
TextView =>  Webview로 내용까지 변경.

<?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:id="@+id/main"  
    android:layout_width="match_parent"  
    android:layout_height="match_parent"  
    tools:context=".MainActivity">  
  
    <WebView        android:id="@+id/webview"  
        android:layout_width="match_parent"  
        android:layout_height="match_parent" />  
  
</LinearLayout>

MainActivity.java

package com.example.test;  
  
import android.os.Bundle;  
import android.webkit.WebView;  
  
import androidx.activity.EdgeToEdge;  
import androidx.appcompat.app.AppCompatActivity;  
import androidx.core.graphics.Insets;  
import androidx.core.view.ViewCompat;  
import androidx.core.view.WindowInsetsCompat;  
  
public class MainActivity extends AppCompatActivity {  
  
    private WebView webView;  
  
    @Override  
    protected void onCreate(Bundle savedInstanceState){  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.activity_main);  
        webView = findViewById(R.id.webview);  
        webView.getSettings().setJavaScriptEnabled(true);  
        webView.getSettings().setMediaPlaybackRequiresUserGesture(false);  
        webView.loadUrl("Https://www.google.com");  
    }  
}

 

우측에 뜨는 모바일 가상 화면이 너무 느려서 변경
pixel 8 - nugget 24 다운로드
변경하니까 금방 열린다. 

 

Image Asset

 

배포하기

Build APK

 

aab 생성

 

 

 

경로 : C:\Users\user\AndroidStudioProjects\Test\app\release

 

 

 

반응형

댓글