Samsung
Retired DISLab
목차 |
첨기연 설정
Key 인증
- 삼성에서 발급한 키값으로 인증을 해야한다.
C:\>keytool -storepass changeit -import -file "d:\samsung.crt" -keystore "C:\Program Files\Java\jdk1.8.0_101\jre\lib\security\cacerts" -alias samsungcert
C:\>cd C:\Program Files (x86)\Java\jdk1.7.0_17\bin C:\Program Files (x86)\Java\jdk1.7.0_17\bin>keytool -storepass changeit -import -file "c:\samsung_university.cer" -keystore "C:\Program Files (x86)\Java\jdk1.7. 0_17\jre\lib\security\cacerts" -alias samsungcert 소유자: EMAILADDRESS=hyoungjeen.yoon@samsung.com, CN=SAMSUNG University, OU=SAMS UNG University, O=SAMSUNG Electronics, L=Yongin, ST=Gyeonggi-do, C=KR 발행자: EMAILADDRESS=hyoungjeen.yoon@samsung.com, CN=SAMSUNG University, OU=SAMS UNG University, O=SAMSUNG Electronics, L=Yongin, ST=Gyeonggi-do, C=KR 일련 번호: 88f6cbee49905a00 적합한 시작 날짜: Sat Dec 28 09:51:55 KST 2013, 종료 날짜: Tue Dec 26 09:51:55 K ST 2023 인증서 지문: MD5: B8:94:C2:00:74:FF:76:0E:D9:28:CA:D0:EA:88:38:17 SHA1: 1A:F6:1D:E8:22:22:88:FB:6E:3F:2E:6F:55:96:05:39:6F:93:EB:AC SHA256: 75:A0:FE:29:22:C5:FA:AA:29:7C:AC:55:A8:1E:EF:F7:8D:98:D0:20:B9: 73:A4:CA:D4:03:6F:04:BE:B6:4F:85 서명 알고리즘 이름: SHA1withRSA 버전: 3 확장: #1: ObjectId: 2.5.29.35 Criticality=false AuthorityKeyIdentifier [ KeyIdentifier [ 0000: 44 6E ED 97 11 6A 2C A4 07 4D 86 CF C2 8C 59 89 Dn...j,..M....Y. 0010: 92 34 11 50 .4.P ] [EMAILADDRESS=hyoungjeen.yoon@samsung.com, CN=SAMSUNG University, OU=SAMSUNG Uni versity, O=SAMSUNG Electronics, L=Yongin, ST=Gyeonggi-do, C=KR] SerialNumber: [ 88f6cbee 49905a00] ] #2: ObjectId: 2.5.29.19 Criticality=false BasicConstraints:[ CA:true PathLen:2147483647 ] #3: ObjectId: 2.5.29.14 Criticality=false SubjectKeyIdentifier [ KeyIdentifier [ 0000: 44 6E ED 97 11 6A 2C A4 07 4D 86 CF C2 8C 59 89 Dn...j,..M....Y. 0010: 92 34 11 50 .4.P ] ] 이 인증서를 신뢰합니까? [아니오]: y 인증서가 키 저장소에 추가되었습니다. C:\Program Files (x86)\Java\jdk1.7.0_17\bin>
Android Studio 설정
- Proxy 설정
- Menu : File/Settings/Appearance & Behavior/System Settings/HTTP Proxy
- 값: 10.241.3.7:8080
- JDK 경로 설정 변경
- Menu : File/Project Structure/SDK Location/JDK location
- uncheck : Use embedded JDK (recommended)
- 경로설정 : C:\Program Files\Java\jdk1.8.0_101
- SDK Manager 설정
- Menu : Tools/Android/SDK Manager/Launch Standalone SDK Manager/Tools/Options
- check : Force https:// ... soources to be fetched using http:// ...
- SDK Dowonload
build.gradle 설정
- proxy 설정 때문에 컴파일이 제대로 되지 않는다. 아래와 같이 project의 build.gradle을 수정한다.
buildscript { repositories { jcenter({url "http://jcenter.bintray.com/"}) } dependencies { classpath "com.android.tools.build:gradle:2.3.3" } } allprojects { repositories { jcenter({url "http://jcenter.bintray.com/"}) } } task clean(type: Delete) { delete rootProject.buildDir }
- 이것은 Android Studio를 띄울때 마다 새로 설정해야 합니다.
- 새로 설정하지 않는 방법은 다음과 같습니다.
- C:\Users\SEC\.gradle\wrapper\dists\gradle-3.3-all\55gk2rcmfc6p2dg9u9ohc3hw9\gradle-3.3\bin 폴더 있는 gradle.bat 파일을 더블클릭해서 실행한다.
- C:\Users\SEC\.gradle 폴더에 init.gradle 파일(아래 내용과 같음)을 복사해 넣는다.
allprojects { buildscript.repositories { jcenter({ url "http://jcenter.bintray.com" }) maven { url "http://10.252.250.53:8081/lm/content/groups/public/" } } buildscript.configurations.all { resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds' resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } repositories { jcenter({ url "http://jcenter.bintray.com" }) maven { url "http://10.252.250.53:8081/lm/content/groups/public/" } } configurations.all { resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds' resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } }
Android Application Project 설정
- gradle.properties에 다음 항목 추가. 실습 PC의 메모리가 적어 힙크기를 줄여야 함.
org.gradle.jvmargs=-Xmx512m systemProp.https.proxyPort=8080 systemProp.https.proxyHost=168.219.61.252 systemProp.http.proxyPort=8080 systemProp.http.proxyHost=168.219.61.252
실습자료
소스 코드 교안 다운로드
아래 코드를 다운로드 받아서 코드를 복사하여 실습합니다. 만약 파일이 zip 형태로 받아진다면, 다운로드 후 확장자를 pptx로 변환하면 됩니다.
한글 입력기 설치 방법
- HangulKeyboard.zip을 다운로드 받아 압축해제한다.
- 에뮬레이터에 설치한다.
C:> adb install HangulKeyboard.apk
예제 프로그램 다운로드
Android 개념 및 개발 환경
II-2. 개발 환경 구축과 샘플 프로그램
II-4. Android 개발 도구
- Ex-Notepad) TraceView - 도구 사용법을 익히기 위하여 설치하는 프로그램. 실행하면 데이터베이스가 만들어진다.
II-5. Activity
II-6. User Interface - Layout & Menu
- Ex-Layout-1) Linear Layout
- Ex-Layout-2) Relative Layout
- Ex-Layout-3) Table Layout
- Ex-ToDoList-2) 리소스 사용하기
II-7. Activity
User Interface, Intent와 Broadcast Receiver
III-1. User Interface - Dialog
- Ex-Dialog-1) Dialog Test
- Ex-Dialog-2) Alert Dialog
- Ex-Dialog-3) AlertDialog List
- Ex-Dialog-4) AlertDialog RedioBox
- Ex-Dialog-5) Progress
- Ex-Dialog-6) ProgressBar
- Ex-Dialog-7) Thread Progress Dialog - User thread에서 UI를 변경하기 위하여
Message
를 사용한다. - Ex-Dialog-8) Custom Dialog
- Ex-Dialog-9) Custome Dialog 2
- Ex-Dialog-10) Activity Dialog
III-2. View
- Ex-Dialog-11) DatePicker
- Ex-View-1) 자동 완성 기능
- Ex-View-2) 입력 필터를 이용한 사용자 입력 제한
- Ex-View-3) Spinner 위젯을 이용한 제한적인 텍스트 입력
- Ex-View-4) GridView
- GridView Icon들 - 이 예제에서 필요한 그림을 나타내는 PNG 파일
- Ex-View-5) TabWidget
- Ex-View-6) Compound Control 만들기
- Ex-View-7) 나침반 뷰 만들기
III-3. User Interface - Resource
III-5. Intent & Adapter 연습
- Ex-Contact-1) Contact Picker - 연락처 예제를 통한 Intent, Adapter 연습
- p.418 : path="contacts" → host="contacts"로 수정
- Ex-ToDoList-5) 사용자 정의 Adapter 연습
III-8. Service - IPC
데이터 저장, Telephony, Notification & Graphics
IV-1. Preference & File
- Ex-File-1) 지정된 경로에 파일 쓰기
- Ex-File-2) 지정된 경로에서 파일 읽기
- Ex-File-3) Raw 리소스 파일에서 읽기
- Ex-File-4) XML 파일 리소스에서 읽기
- Ex-File-5) SD 카드에 파일 생성 및 저장
- Ex-File-6) SD 카드에서 파일 읽기
- Ex-ToDoList-6) Preference 연습
IV-2. Database
IV-4. Network & Web
- Ex-Earthquake-1) 지진 뷰어 만들기 (XML 문서 Parsing)
- http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.quakeml
- http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.atom
- 인터넷을 사용하려면 에뮬레이터에 proxy 설정을 해야 합니다. (10.241.3.7:8080)
- 코드를 아래와 같이 수정합니다.
protected Void doInBackground(Void... params) { Log.e("Earthquake", "doInBackground() is called.\n"); // Get the XML URL url; try { TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(X509Certificate[] certs, String authType) { } public void checkServerTrusted(X509Certificate[] certs, String authType) { } } }; SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); // proxy가 설정되어 있는 경우 //Properties systemProperties = System.getProperties(); //systemProperties.setProperty("http.proxyHost", "10.241.3.7"); //systemProperties.setProperty("http.proxyPort", "8080"); String quakeFeed = getString(R.string.quake_feed); url = new URL(quakeFeed); Log.e("Earthquake", "doInBackground() is called.2\n"); URLConnection connection = url.openConnection(); HttpURLConnection httpConnection = (HttpURLConnection)connection; Log.e("Earthquake", "doInBackground() is called.3\n"); int responseCode = httpConnection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { Log.e("Earthquake", "Succeeded http request..($1)\n"); InputStream in = httpConnection.getInputStream(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); // 지진 피드를 파싱한다. Document dom = db.parse(in); Element docEle = dom.getDocumentElement(); // 지난 지진 정보는 지운다 earthquakes.clear(); // 각각의 지진 입력 리스트를 가져온다. NodeList nl = docEle.getElementsByTagName("event"); if (nl != null && nl.getLength() > 0) { for (int i = 0 ; i < nl.getLength(); i++) { Element entry = (Element)nl.item(i); String details = getValue(entry, "description", "text"); String latitude = getValue(entry, "latitude"); String longitude = getValue(entry, "longitude"); String mag = getValue(entry, "mag"); String when = getValue(entry, "time"); if (details == null || latitude == null || longitude == null || mag == null || when == null) continue; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSS'Z'"); Date qdate = new GregorianCalendar(0,0,0).getTime(); try { qdate = sdf.parse(when); } catch (java.text.ParseException e) { e.printStackTrace(); } Location l = new Location("dummyGPS"); l.setLatitude(Double.parseDouble(latitude)); l.setLongitude(Double.parseDouble(longitude)); double magnitude = Double.parseDouble(mag); Quake quake = new Quake(qdate, details, l, magnitude); Log.e("Earthquake", quake.toString() + "\n"); publishProgress(quake); } } } else { String msg = String.format("$1", responseCode); Log.e("Earthquake", String.format("Failed http request..($1)\n", msg)); } } catch (Exception e) { e.printStackTrace(); } return null; }
IV-5. Telephony, Notification & Alarm
- Ex-Phone-1) 전화 통화 모니터링
- Ex-Phone-2) 셀 위치변화 추적하기
- Ex-Phone-3) SMS 메시지 보내기
- Ex-Toast-1) Customizing Toast - Toast를 화면 아래 정렬
- Ex-Toast-2) Customizing Toast - Toast 객체에 setView 사용
- Ex-Toast-3) Customizing Toast - 작업자 쓰레드에서 Toast 사용하기
- Ex-Notification-1) Notification 만들기
- Ex-Notification-1) 고급 Notification 기법
- Ex-Alarm-1) 알람 예제
IV-6. Graphics
- Ex-Graphic-1) 간단한 위젯
- Ex-Graphic-2) 페인트 위젯
- Ex-Graphic-3) 텍스트를 그리는 세 가지 방법 - Source Code
- Ex-Graphic-4) Canvas Transform
- Ex-Graphic-5) Canvas Transform - TextDrawable 사용하기
- Ex-Graphic-6) Canvas Transform - 비트맵 캐싱
IV-7. Media Framework
- Ex-Multimedia-1) MediaPlayer (Audio)
- Ex-Multimedia-3) 음성 재생
- Ex-Multimedia-2) VideoPlayer
- Ex-Multimedia-4) 음성 녹음
- Ex-Multimedia-5) 영상 녹화
IV-8. Sensors
위치기반 서비스 & Field Application
V-1. Map
V-2. 위치기반서비스 - GPS
V-4. Preference
컴파일할 때 아래의 오류가 날 경우
The number of method references as a .dex file cannot exceed 64K.
build.gradle 파일을 아래와 같이 수정합니다.
android { ... defaultConfig { ... ... // Enabling multidex support. multiDexEnabled true } dependencies { ... compile 'com.android.support:multidex:1.0.0' }
그리고 Manifest 파일을 다음과 같이 수정합니다.
<application ... android:name="android.support.multidex.MultiDexApplication"> ... </application> </manifest>