본문 바로가기

분류 전체보기20

안드로이드 디자인패턴 MVC와 MVP의 차이? 오늘은 안드로이드에서 정말 중요하다고 할 수 있는 디자인 패턴 MVC, MVP에 대해서 알아볼 것이다. 사실 가장 많이 쓰이는 패턴은 MVVM이지만 그래도 다른 패턴들 먼저 알아보고자 한다. 그래서 오늘은 MVC와 MVP 패턴의 차이를 먼저 알아볼 것이다. MVC 먼저 MVC 패턴에 대해서 간단하게 설명해보면 MODEL : 데이터 관리 View : 유저에게 보여주는 화면 Controller : 사용자의 요청을 인식하여 Model에서 요청에 맞는 데이터를 가져오고 View에 적용 안드로이드에서의 MVC 안드로이드에서 MVC를 매칭시켜보면 View : Activty(View, Fragment) Controller : Activity(Button.setOnClickListener) Model : Model V.. 2023. 4. 24.
안드로이드 Webview 사용법 및 Intent를 이용한 Activity에서 Fragment로 데이터전달 오늘은 안드로이드 앱에서 Webview를 구현하는 방법과 Intent를 이용해서 Acitvity에서 Fragment로 데이터를 전달하는 방법에 대해서 알아볼 것이다. Webview부터 차근차근 알아보자 Webview 구현 기본적으로 Webview를 구현하기 위해 쓰일 Activity를 만들어주었다. WebviewActivity.java @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_webview1); String url = "웹뷰를 구현할 링크"; webview.loadUrl(url); webview.setWebChr.. 2023. 4. 23.
안드로이드 Fragment에서 현재 위치(위도, 경도) 가져오는 방법 오늘은 Fragment에서 현재 위치(위도, 경도)를 가져오는 방법에 대해서 알아볼 것이다. 코드를 통해 차근차근 알아보자 GpsTracker.java 먼저 GpsTraker 코드부터 보겠다. package com.example.pethealth; import android.Manifest; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.location.Location; import android.location.LocationListener; import android.location.L.. 2023. 4. 23.
안드로이드 CountDownTimer 사용해서 버튼 활성화하는 방법 오늘은 작업하던 앱에서 CountDownTimer를 사용할 일이 생겼다. 사용한 내용에 대해서 정리해보려고 한다. class TimerRest extends CountDownTimer { public TimerRest(long millisInFuture, long countDownInterval) { super(millisInFuture, countDownInterval); } @Override public void onTick(long millisUntilFinished) { // To-Do } @Override public void onFinish() { } } 위 코드는 CountDownTimer의 기본 형식이다. 맨 처음에 CountDownTimer를 상속받는 클래스를 생성해주고 Timer가 필요.. 2023. 4. 23.