http://www.vogella.com/tutorials/AndroidBackgroundProcessing/article.html#concurrency_handler
2018년 3월 28일 수요일
2018년 3월 5일 월요일
[Android] setBackgroundResource VS setImageResource
무슨 차이가 있을까요? 결론부터 말씀드리면,
setBackgroundResource는 이미지뷰의 백그라운드의 크기에 맞게 설정되고,
setImageResource는 이미지뷰의 src 이미지를 설정합니다.
그게 뭔 말인지... 헷갈리신다고요?
그 차이는 이미지 자체의 크기가 작을 때 극명하게 나뉘는데요, 이미지 자체가 이미지뷰보다 상대적으로 작다고 할 때, setBackgroundResource는 이미지 자체를 크게 늘려서 이미지뷰의 크기만큼 보여주고, setImageResource는 이미지뷰의 크기만큼만 보여준다는 차이점이 있습니다.
출처 : https://stackoverflow.com/questions/7221673/what-is-the-difference-between-imageview-setbackgroundresource-and-imageview-set
setBackgroundResource는 이미지뷰의 백그라운드의 크기에 맞게 설정되고,
setImageResource는 이미지뷰의 src 이미지를 설정합니다.
그게 뭔 말인지... 헷갈리신다고요?
그 차이는 이미지 자체의 크기가 작을 때 극명하게 나뉘는데요, 이미지 자체가 이미지뷰보다 상대적으로 작다고 할 때, setBackgroundResource는 이미지 자체를 크게 늘려서 이미지뷰의 크기만큼 보여주고, setImageResource는 이미지뷰의 크기만큼만 보여준다는 차이점이 있습니다.
출처 : https://stackoverflow.com/questions/7221673/what-is-the-difference-between-imageview-setbackgroundresource-and-imageview-set
2018년 3월 2일 금요일
[Android] 멀티 덱스? What is MultiDex?
1. 멀티텍스는 무엇인가요?
한마디로 여러 개의 덱스 파일을 사용할 수 있다는 것입니다. 아래의 설명에서 보듯이, 안드로이드 파일은 파일 한 개당 65,536 메소드/프레임워크/라이브러리 등을 가질 수 있습니다. API 21 미만에서는 65,536이 넘어가게 되면 멀티덱스 지원라이브러를 사용해야 하고, API 21 이상에서는 설정만 가볍게 바꾸면 됩니다. 물론 API 21 이하에서도 쉽습니다만 지원라이브러를 꼭 추가해줘야 합니다.
# stackoverflow
2. 그렇다면 멀티덱스는 어떻게 사용하나요?
API 21이상이라면,
API21이하라면,
출처 :
https://stackoverflow.com/questions/33588459/what-is-android-multidex
https://developer.android.com/studio/build/multidex.html?hl=ko#about
https://developer.android.com/reference/android/support/multidex/MultiDex.html
https://developer.android.com/topic/libraries/support-library/features.html?hl=ko#v7
https://developer.android.com/studio/build/multidex.html?hl=ko
https://ko.wikipedia.org/wiki/%EB%8B%AC%EB%B9%85_(%EC%86%8C%ED%94%84%ED%8A%B8%EC%9B%A8%EC%96%B4)
https://source.android.com/devices/tech/dalvik/dex-format
한마디로 여러 개의 덱스 파일을 사용할 수 있다는 것입니다. 아래의 설명에서 보듯이, 안드로이드 파일은 파일 한 개당 65,536 메소드/프레임워크/라이브러리 등을 가질 수 있습니다. API 21 미만에서는 65,536이 넘어가게 되면 멀티덱스 지원라이브러를 사용해야 하고, API 21 이상에서는 설정만 가볍게 바꾸면 됩니다. 물론 API 21 이하에서도 쉽습니다만 지원라이브러를 꼭 추가해줘야 합니다.
# stackoverflow
It's as simple as this
A single .dex file can have 65,536 methods(references) so if the number of references exceed 65,536, you go with multidex.
More Explanation !
An android application program is compiled into a .dex file which in turn zipped to a single .apk file.
DVM (Dalvik Virtual Machine) uses .dex file/files to execute bytecodes.
DVM (Dalvik Virtual Machine) uses .dex file/files to execute bytecodes.
What causes number of references to exceed 65,536 limit ?
Methods written by you + Android Framework methods + Third party library(eg Volley,Retrofit,Facebook SDK etc) methods.
I have read "somewhere"
App Compat 24.2.1 contains 16.5k methods
Google Play Services GCM 9.6.1 contains 16.7k methods
So if you have created a simple Hello world application which has App Compat 24.2.1, you are already 1/4 way to cross the single dex methods limit
#AndroidDeveloperMethods written by you + Android Framework methods + Third party library(eg Volley,Retrofit,Facebook SDK etc) methods.
I have read "somewhere"
App Compat 24.2.1 contains 16.5k methods
Google Play Services GCM 9.6.1 contains 16.7k methods
So if you have created a simple Hello world application which has App Compat 24.2.1, you are already 1/4 way to cross the single dex methods limit
Android 플랫폼이 계속 성장함에 따라 Android 앱의 크기도 따라서 증가합니다. 앱과 이 애플리케이션이 참조하는 라이브러리의 크기가 일정 크기에 도달하면, 앱이 Android 앱 빌드 아키텍처의 제한에 도달했음을 나타내는 빌드 오류가 발생합니다. 이전 버전의 빌드 시스템에서는 이 오류를 다음과 같이 보고합니다.
Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536
그보다 최근의 Android 빌드 시스템 버전에서는 다른 오류를 표시하지만 이 오류는 동일한 문제를 나타내는 것입니다.
trouble writing output: Too many field references: 131000; max is 65536. You may try using --multi-dex option.
두 오류 모두 공통 숫자인 65,536을 표시합니다. 이 숫자는 단일 DEX(Dalvik Executable) 바이트코드 파일 내에서 코드가 호출할 수 있는 참조의 총 개수를 나타냅니다. 이 페이지에서는 multidex라는 앱 구성을 활성화하여 이 제한을 넘는 방법을 설명합니다. multidex는 앱이 다중 DEX 파일을 빌드하고 읽을 수 있게 해줍니다.
API 21이상이라면,
android { defaultConfig { ... minSdkVersion 21 targetSdkVersion 26 multiDexEnabled true } ... }
API21이하라면,
android { defaultConfig { ... minSdkVersion 15 targetSdkVersion 26 multiDexEnabled true } ... } dependencies { compile 'com.android.support:multidex:1.0.1' }
출처 :
https://stackoverflow.com/questions/33588459/what-is-android-multidex
https://developer.android.com/studio/build/multidex.html?hl=ko#about
https://developer.android.com/reference/android/support/multidex/MultiDex.html
https://developer.android.com/topic/libraries/support-library/features.html?hl=ko#v7
https://developer.android.com/studio/build/multidex.html?hl=ko
https://ko.wikipedia.org/wiki/%EB%8B%AC%EB%B9%85_(%EC%86%8C%ED%94%84%ED%8A%B8%EC%9B%A8%EC%96%B4)
https://source.android.com/devices/tech/dalvik/dex-format
2018년 3월 1일 목요일
[Android] Cursor란 무엇인가
Cursor란 무엇인가?
Cursor는 안드로이드에서 제공하는 인터페이스로서, SQLite에서 필요한 데이터를 편하게 쓸 수 있도록 배려하였다. 하나의 행 단위로 만들었기 때문에 JSON처럼 데이터가 묶여있다고 생각하면 된다. 예를 들면,
Cursor cursor = myDb.getAllData(); //myDb는 SQLite 생성/추가/수정/삭제를 클래스의 객체다.
cursor.moveToFirst(); //이 코드는 첫번째 행으로 이동한다. 없으면 에러가 생긴다.
cursor.getString(0); //getString에서 String은 변수형이고 0은 컬럼값이다. 첫번째 행은 0부터 시작한다.
Source :
http://arabiannight.tistory.com/entry/368
https://developer.android.com/reference/android/database/Cursor.html
Cursor는 안드로이드에서 제공하는 인터페이스로서, SQLite에서 필요한 데이터를 편하게 쓸 수 있도록 배려하였다. 하나의 행 단위로 만들었기 때문에 JSON처럼 데이터가 묶여있다고 생각하면 된다. 예를 들면,
Cursor cursor = myDb.getAllData(); //myDb는 SQLite 생성/추가/수정/삭제를 클래스의 객체다.
cursor.moveToFirst(); //이 코드는 첫번째 행으로 이동한다. 없으면 에러가 생긴다.
cursor.getString(0); //getString에서 String은 변수형이고 0은 컬럼값이다. 첫번째 행은 0부터 시작한다.
Source :
http://arabiannight.tistory.com/entry/368
https://developer.android.com/reference/android/database/Cursor.html
피드 구독하기:
글 (Atom)