본문 바로가기

Android

SwitchCompat 스타일로 디자인 적용하기 SwitchCompat SwitchCompat link 기본 디자인 입히기 뒷배경 track 과 스위치 아이콘 thumb 부분의 drawable 을 수정해서 커스텀 할 수 있다. Thumb Drawble state_checkd 를 통해서 checked 상태와 unchecked 상태를 설정한다. shape_switch_thumb_on shape_switch_thumb_off Track Drwable state_checkd 를 통해서 checked 상태와 unchecked 상태를 설정한다. shape_switch_track_on shape_switch_track_off 전체 코드 원하는 디자인과 조금 다른 짜리몽땅한 모습이 보여진다. (약 34dp) 가로 길이를 조정하기 위해서는 app:switchMinWi.. 더보기
Android Proguard Obfuscating and Shrinking your code 프로가드를 통해서 안드로이드 프로젝트의 난독화와 최적화를 할 수 있다. obfuscate: 난독화 Shrink : 수축, 축소 optimize : 최적화 Android Gradle 플러그인 3.4.0 이상을 사용하여 프로젝트를 빌드하는 경우 플러그인은 더 이상 ProGuard를 사용하여 컴파일 시간 코드 최적화 작업을 하지 않습니다. 대신 플러그인은 R8 컴파일러를 이용하여 다음의 컴파일 시간 작업을 처리합니다. proguard 설정 방법 android { buildTypes { debug { mifinyEnalbled false } release { // Enables code shrinking, obfuscation, and optimi.. 더보기
Retrofit + Rx + JUnit 으로 api test 하기 Retofit 을 RX 로 Wrapping 해서 API test 를 실행할 수 있다. Junit5 Gradle 설정testImplementation 'org.junit.jupiter:junit-jupiter-api:5.2.0' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.2.0'Retrofit Gradle 설정implementation 'com.squareup.retrofit2:retrofit:2.4.0' implementation 'com.squareup.retrofit2:converter-gson:2.4.0' implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0' implementa.. 더보기
Notification icon Size 내가 갖고 있는 nexus 5 에서 노티가 제대로 보이지 않는게 문제였다. http://developer.android.com/design/style/iconography.html 위 링크를 보면 24 dp 를 기준으로 디자인 하면 된다고 하는데, 해 봐도 내가 원하는 모습이 아니다. 그럼 어떻게 할까? basicNotifications (http://developer.android.com/samples/BasicNotifications/index.html) 샘플을 다운 받아서 보면 정답이 나와있다. 11 개의 아이콘 파일 hdpi : 38 x 38hdpi-v11: 36 x 36hdpi-v9: 24 x 38ldpi-v11: 18 x 18ldpi-v9: 12 x 19mdpi: 25 x 25mdpi-v11:.. 더보기
AIDL 로 service binding하기 AIDL (android interface definitionlanguage) 를 이용하는 방법 Activity 와 Service을 bind하여 사용하는 sample을 작성하였다. activity와 service에 동일한 형태의 aidl 파일을 작성하고 그 형태에 맞게 호출하면 된다. ㅋㅋ 자세한 내용은 소스 참고! 더보기
apk install File apkFile = new File("/sdcard/UpgradeTest.apk"); if (apkFile == null) { Log.i(TAG, "file is null"); } Uri uri = Uri.fromFile(apkFile); Intent it = new Intent(Intent.ACTION_VIEW, uri); it.setData(uri); it.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK); it.setClassName("com.android.packageinstaller", "com.android.packageinstaller.PackageInstallerActivity"); star.. 더보기
Android so upgrade Manifest.xml에 존재하는 version 정보를 이용하여 upgrade를 시도할 수 있다. Adb install 을 이용하여 최초 버전 install 이후에는 adb install로 upgrade 불가하며 adb push 를 통하여 /data/app/ 에 넣어야 함 버전 별 포함하고 있는 so와 push 후 data/data/app/lib에 존재하는 so 파일은 다음과 같습니다. version 1: 1.so data/data/app/lib : 1.so 존재 version 2: 1-1.so , 2.so data/data/app/lib : 1-1.so, 2.so 존재 version 3: 1-2.so data/data/app/lib : 1-2.so , 2.so 존재 결과 : upgrade를 통하여 부분.. 더보기
dumpstate dumpsys adb 명령어 중 dump 관련된 명령어 2개 dumpstate 호출 시 다음과 같은 정보가 보여진다. 뭔가 엄청 많은데 사실 봐도 잘 모르겠다. T.T ------ MEMORY INFO ------ ------ CPU INFO ------ ------ PROCRANK ------ ------ VIRTUAL MEMORY STATS ------ ------ VMALLOC INFO ------ ------ SLAB INFO ------ ------ ZONEINFO ------ ------ SYSTEM LOG ------ ------ VM TRACES ------ ------ EVENT LOG TAGS ------ ------ EVENT LOG ------ ------ RADIO LOG ------ -----.. 더보기
Kernel build kernel build > cd ~/mydroid > git clone git://android.git.kernel.org/kernel/common.git kernel > cd kernel > git branch * android-2.6.27 > git clone git://android.git.kernel.org/kernel/common.git kernel > git branch android-2.6.27 * android-2.6.29 for ADM64 + Ubuntu 9.10 > dpkg --get-selections | grep -v deinstall (install package listing...) 더보기
Toast Message 사용하기 Android application에서 Toast Message를 사용하면 어플리케이션 상황과 관계없이 system UI를 살짝 그릴 수 있다. 별로 대단한 일은 아니지만... 굳이 팝업 같은걸 만들어서 관리하는것 보다 잠깐 잠깐 noti를 주기에는 충분한거 같다 static Class Toast의 함수를 호출 하면 간단하게 ~ 해결 파라미터를 보면 첫번째가 activity에서 갖고오는 appllicationContext, 두번째가 보여주고 싶은 문구 "String값", 3번째가 시간, LENGTH_LONG, LENGTH_SHORT 또는 직접 시간을 넣을 수도 있다. Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show(); Toast.. 더보기