Presentation is loading. Please wait.

Presentation is loading. Please wait.

Android 세미나 2010년 11월.

Similar presentations


Presentation on theme: "Android 세미나 2010년 11월."— Presentation transcript:

1 Android 세미나 2010년 11월

2 목차 01 02 03 04 프로그램 설명 나인 패치 적용법 SMS & Contact DB 접근 기타 Tip
Package & Activity 설명 02 나인 패치 적용법 03 SMS & Contact DB 접근 기타 Tip 04 문자 보내기 전화 걸기 & 자기전화번호 추출 Style 사용가능 옵션

3 01 프로그램 설명 Package 설명 Activity 설명

4 문자보관함이랑 관련된 패키지 DB 정의 및 관련 함수 받은 메시지 관련 패키지 보낸 메시지 관련 패키지
1. 프로그램 설명 Package 설명 com.DevilBBong.MailEngine 기본적으로 사용되는 java 파일 com.DevilBBong.MailEngine.CustodyBox 문자보관함이랑 관련된 패키지 com.DevilBBong.MailEngine.Database DB 정의 및 관련 함수 com.DevilBBong.MailEngine.ReceiveBox 받은 메시지 관련 패키지 com.DevilBBong.MailEngine.SendBox 보낸 메시지 관련 패키지 com.DevilBBong.MailEngine.WriteLetter 문자 보내기 관련 패키지

5                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            02 나인패치 적용법

6 Stretchable area Padding box. 확장이 되며 늘어날 영역 1 TextView가 그려질 영역
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           2. 나인패치 적용법 9 patch(나인패치) drawable 이란? Stretchable area 확장이 되며 늘어날 영역 Padding box. TextView가 그려질 영역 1 파일이름은 반드시 .9.png라고 끝나도록 저장해주어야 합니다. res/drawable/some_name.9.png 와 같은 형태가 되겠죠. 만약 그냥 .png라고 끝난다면 일반 이미지 파일로 처리가 됩니다. 2

7 1. SDK/tools/draw9patch.exe
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           2. 나인패치 적용법 9 patch(나인패치) drawable 이란? 1. SDK/tools/draw9patch.exe

8 03 SMS & Contact DB 접근

9 3. SMS DB 접근 SMS DB값 가져오기 data/data/com.android.providers.telephony/mmssms.db

10 데이터베이스에서 원하는 Cursor를 받아오기 : 쿼리(query; 질의)
3. SMS DB 접근 DB값 가져오기 데이터베이스에서 원하는 Cursor를 받아오기 : 쿼리(query; 질의) 원하는 데이터베이스를 가져와야 합니다. 이는 쿼리(Query; 질의)를 통해 이루어집니다. 질의 결과는 Cursor객체 형태로 반환됩니다. public final Cursor query (Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) uri 질의를 수행할 테이블의 uri입니다. projection 자료를 받아올 필드들입니다. null을 입력하면 모든 필드를 반환합니다. selection  SQL의 "where" 구문에 해당되는 조건을 입력합니다. 조건이 많을 경우, ?로 대체합니다. selectionArgs   selection을 ?로 지정하였을 경우, 그 조건들을 입력합니다. sortOrder   결과값 정렬 방식을 지정합니다. null을 입력하면 기본 정렬을 수행합니다. 예제 ) // 모든 레코드를 반환하는 쿼리를 실행합니다. Cursor all = myDB.query("data", null, null, null, null, null, null, null); // 받은 문자메세지 레코드를 반환하는 쿼리를 실행합니다. Uri uri = Uri.parse("content://sms"); String[] projection = { "_id", "address", "person", "date", "body" }; String where = "person is null"; Cursor cursorReceive = ((Activity) mContext).getContentResolver().query(uri, projection, where, null, null);

11 Cursor에서 원하는 Data를 받아오기
3. SMS DB 접근 DB값 가져오기 Cursor에서 원하는 Data를 받아오기 Cursor는 가져온 DB table의 한 Row를 가리킵니다. 그리고 이 가져온 Cursor에서 원하는 Data를 가져와야 합니다. 이는 getXXX(ColumnIndex)으로 이뤄 집니다. 질의 결과는 해당 Type으로 반환됩니다. moveToFirst()  커서가 쿼리 결과 레코드들 중에서 가장 처음에 위치한 레코드를 가리키도록 함 moveToNext()  다음 레코드로 커서를 이동합니다. moveToPrevious()  이전 레코드로 커서를 이동합니다. getCount()  질의 결과값(레코드)의 갯수를 반환합니다. getColumnIndexOrThrow()  특정 필드의 index값을 반환하며, 필드가 존재하지 않을경우 예외를 발생 getColumnName()  특정 인덱스값에 해당하는 필드 이름을 반환합니다. getColumnNames()  필드 이름들을 String 배열 형태로 반환합니다. moveToPosition()  커서를 특정 레코드로 이동시킵니다. getPosition()  커서가 현재 가리키고 있는 위치를 반환합니다. 예제 ) receiver = cursor.getString(cursor.getColumnIndex("address")); // index = 2 sender = cursor.getString(cursor.getColumnIndex("person")); // index = 3 letter = cursor.getString(cursor.getColumnIndex("body")); // index = 10 date = cursor.getString(cursor.getColumnIndex("date")); // index = 4 item_sms = new Item_SMS(receiver, sender, letter, date); sms_list.add(count++, item_sms);

12 3. Contact DB 접근 Contact DB 가져오기 DB값 가져오기 1. MatrixCursor 사용
Android 2.0버전 부터 주소록 DB구조가 변경 되었다. 1. MatrixCursor 사용 DB 테이블을 보니, 한 row에 전화번호랑 이름이 같이 들어가 있는 구조가 아니어서.. 전화번호를 하나의 Cursor로 받고, 이름도 하나의 Cursor로 받아서 MatrixCursor로 합쳐야 할 것 같았다..

13 3. Contact DB 접근 Contact DB 가져오기 DB값 가져오기 2. Provider 사용
두 개의 커서를 받아와 합치려고 했다. MatrixCursor의 사용법을 찾기 위해 검색하던 도중.. 더 좋은 방법을 발견 2. Provider 사용

14 04 기타 Tip 문자 보내기 Style 사용가능 옵션 전화 걸기 & 자기전화번호 추출

15 4. 기타 Tip 문자 보내기 문자 보내기 /** * Send SMS message
context context phoneNumber phone number to send message the text of a letter */ public void sendSMS(Context context, String phoneNumber, String message) throws Exception { String SENT = "SMS_SENT"; String DELIVERED = "SMS_DELIVERED"; PendingIntent sentPI = PendingIntent.getBroadcast(context, 0, new Intent(SENT), 0); PendingIntent deliveredPI = PendingIntent.getBroadcast(context, 0, new Intent(DELIVERED), 0); SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI); } 참고) PendingIntent :

16 4. 기타 Tip 전화 걸기 전화 걸기 & 자기전화번호 추출 /** * 음성통화 실행 함수
context context phone phone number to send */ public void RunAudioCall(Context context, String phone) { if (phone != null) { try { Log.d("Call", "Call : " + phone); context.startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone))); } catch (Exception e) { e.printStackTrace(); }

17 4. 기타 Tip 자기전화번호 추출 전화 걸기 & 자기전화번호 추출 /** * Check your phone number
context context String PhoneNumber */ public String checkMyNumber(Context context) { TelephonyManager mTelephonyMgr = (TelephonyManager); context.getSystemService(Context.TELEPHONY_SERVICE); return mTelephonyMgr.getLine1Number(); }

18 4. 기타 Tip Style 사용가능 옵션 Style 사용가능 옵션
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="DialogTransparent"> <item <item name="android:windowNoTitle">true</item> <item name="android:windowIsTranslucent">false</item> </style> <style name="Theme.AddUserPopup" parent="android:style/Theme.Dialog"> <item <item </resources> 참고)

19 감사합니다.


Download ppt "Android 세미나 2010년 11월."

Similar presentations


Ads by Google