본문 바로가기

프로그래밍/Android

(27)
위젯 1:1 크기 계산 - 위젯 사이즈는 1:1 비율로 만들기 위해, 위젯 크기를 구해서 상하단의 padding 값을 빼줬다. padding = (height - width) / 2 - 홈 화면 세로모드, 가로모드에 대응하기 위해 세로모드일 때의 padding 과 가로모드일 때의 padding 을 각각 구했고, 가로모드 일때도 1:1 비율로 유지되도록 구현했다. (paddingVertical, paddingHorizontal) remoteViews.setViewPadding(R.id.layout_widget, paddingHorizontal, paddingVertical, paddingHorizontal, paddingVertical) - 근데 자고일어나면 위젯이 찌그러져있는 버그를 발견함 - padding 값을 제대로 계산하..
Android Kotlin Fundamentals's Context Lesson 1: Build your first app 1.0 Install Android Studio 1.1 Get started 1.2 Basic app anatomy 1.3 Image resources and compatibility 1.4 Learn to help yourself Lesson 2: Layouts 2.1 Linear layout using the Layout Editor 2.2 Add user interactivity 2.3 Constraint layout using the Layout Editor 2.4 Data-binding basics Lesson 3: Navigation 3.1 Create a fragment 3.2 Define navigation paths 3.3 Start..
Android Firebase FCM Firebase Cloud Messaging 먼저 앱과 Firebase 를 연결한다. 앱을 처음 실행할 때 FirebaseInstanceId로 token을 발급받는다. 그리고 push 알림을 받을 service를 생성한다. service는 안드로이드 백그라운드에서 실행되는 작업을 수행할 수 있는 애플리케이션 4대 구성요소 중 하나로 UI를 제공하지 않는다는 특징이 있다. AndroidMenifest.xml 에 Service를 명시하고 intent-filter에 Fireabase Messaging Event를 작성한다. meta-data 로 default app icon과 channel id 를 명시할 수 있고, token이 자동초기화 되는걸 방지할 수 있다. Service class에서 onNewToke..
LayoutInflater.from(context) vs context.getSystemService(LAYOUT_INFLATER_SERVICE) LayoutInflater.from(context) vs context.getSystemService(LAYOUT_INFLATER_SERVICE) https://stackoverflow.com/a/20995083/9757951 getSystemService : A LayoutInflater for inflating layout resources in this context. 이 Context에서 Layout Resource를 확장하는 LayoutInflater LayoutInflater : Obtains the LayoutInflater from the given context. Context로 부터 LayoutInflater를 가져온다. Activity 내부에선 getLayoutInflater() 를 ..
Android Thread Handler Process : Program의 instance Process 간에는 메모리를 공유하지 않는다. Thread : 작업을 수행하는 객체로 Scheduler에 의해 관리, 실행된다. Process는 1개 이상의 Thread를 갖는다. 같은 Process 내에 Thread들은 메모리를 공유한다. Process : 회사 MainThread : 대표 Thread : 직원 Resource : 프린터 등등 자원 * 자원은 다른 회사(Process)와 공유하지 않는다. Thread 사용하는 방법 1) Runnable 이용 2) Thread 상속 ThreadPool : 몇 개의 Thread로 여러 작업을 수행하게 한다. (Thread 재활용) ThreadPoolExecutor로 생성 ThreadLocal : Threa..
Android capture http://yonoo88.tistory.com/20
Activity를 상속받지 않은(extends 하지 않은) 클래스에서의 intent Relative layout을 상속받은 custom layout 을 상속받은 ~~~ view class 가 있다. 내 목적은 이 class에서 갤러리에 접근하고, 갤러리에서 받은 사진을 imageview에 setImageBitmap하는 것이었다. 이 class 는 activity 를 상속받은 것이 아니기 때문에, 갤러리에 접근하기 위해서는 intent.setAction(Intent.ACTION_GET_CONTENT);intent.setType("image/*");intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);mContext.startActivity(intent); 위와같이 flag를 FLAG_ACTIVITY_NEW_TASK로 해줘야 한다. 또한, startActivi..
Installation failed due to invalid APK file! Installation failed due to invalid APK file!Please check logcat output for more details.Launch canceled! http://stackoverflow.com/questions/7998101/eclipse-installation-failed-due-to-invalid-apk-file Posibility 1: version problem. Make your minimum and target sdk version higher and try again.Posibility 2: package mistmatching. Package name in AndroidManifest.xml does not match with the actual pa..