'Android'에 해당되는 글 4건
- 2010.06.10 [Android] Content Provider
- 2010.01.14 [Android] 하나의 Project에 여러 Activity 추가
- 2009.09.18 [Android] 기존 만들어둔 소스로 실행하기
- 2009.03.06 Android Emulator에 설치된 패키지 삭제법
Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); while (cursor.moveToNext()) { String contactId = cursor.getString(cursor.getColumnIndex( ContactsContract.Contacts._ID)); String hasPhone = cursor.getString(cursor.getColumnIndex( ContactsContract.Contacts.HAS_PHONE_NUMBER)); if (Boolean.parseBoolean(hasPhone)) { // You know have the number so now query it like this Cursor phones = getContentResolver().query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = "+ contactId, null, null); while (phones.moveToNext()) { String phoneNumber = phones.getString( phones.getColumnIndex( ContactsContract.CommonDataKinds.Phone.NUMBER)); } phones.close(); } Cursor emails = getContentResolver().query( ContactsContract.CommonDataKinds.Email.CONTENT_URI, null, ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = " + contactId, null, null); while (emails.moveToNext()) { // This would allow you get several email addresses String emailAddress = emails.getString( emails.getColumnIndex( ContactsContract.CommonDataKinds.CommonDataColumns.DATA)); } emails.close(); } cursor.close();
Cursor people = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); while(people.moveToNext()) { int nameFieldColumnIndex = people.getColumnIndex(PhoneLookup.DISPLAY_NAME); String contact = people.getString(nameFieldColumnIndex); int numberFieldColumnIndex = people.getColumnIndex(PhoneLookup.NUMBER); String number = people.getString(nameFieldColumnIndex); } people.close();
private String getNote(long contactId) { String note = null; String[] columns = new String[] { ContactsContract.CommonDataKinds.Note.NOTE }; String where = ContactsContract.Data.RAW_CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ?"; String[] whereParameters = new String[]{Long.toString(contactId), ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE}; Cursor contacts = getContentResolver().query (ContactsContract.Data.CONTENT_URI, projection, where, whereParameters, null); if (contacts.moveToFirst()) { rv = contacts.getString(0); } contacts.close(); return note; }
package com.ncfp.rataplan; import android.app.Activity; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.ContactsContract; import android.widget.TextView; public class ContactsView extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView contactView = (TextView) findViewById(R.id.contactview); Cursor cursor = getContacts(); while (cursor.moveToNext()) { String displayId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID)); String displayName = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); String hasPhone = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)); contactView.append("Name: "); //contactView.append(displayId); contactView.append(displayName); contactView.append(hasPhone); //contactView.append("\n"); if(!Boolean.parseBoolean(hasPhone)) { contactView.append("_"); Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID+" = "+ displayId, null, null); while(phones.moveToNext()) { String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); contactView.append(phoneNumber); contactView.append("\n"); } } } } private Cursor getContacts() { // Run query Uri uri = ContactsContract.Contacts.CONTENT_URI; String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.HAS_PHONE_NUMBER }; String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '" + ("1") + "'"; String[] selectionArgs = null; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; //return managedQuery(uri, projection, selection, selectionArgs, sortOrder); return managedQuery(uri, null, null, null, null); } }
* 각 Activity가 연결성을 갖지는 않음.
* 각 Activity는 개별 테스트 프로그램일뿐
1. 초기 Project를 생성후 초기 Activity가 존재함
새로운 또다른 Activity를 만들어 별도 프로그램으로 생성(테스트를 위해 종종 사용)
2. 수정할 내용
- java 프로그램의 setContentView의 layout 명을 지정한 xml 파일로 변경
- 위에 지정한 xml을 생성해줌(화면 layout을 위한 xml파일)
- AndroidManifest.xml 파일을 수정
+ 새로 생성한 java이 구동되게 설정하려면... 이전 Activity 정보에서 category 테그는 DEFAULT를
제거함
1) 소스에 적절한 프로젝트 설정 파일이 있을 경우 :
File -> Import -> General -> Existing Projects into Workspace -> 소스 디렉토리 선택
2) 버젼 문제등으로 적절한 프로젝트 설정 파일이 없을 경우(invalid project description message)
소스 파일을 Workspace 밖으로 이동한다 -> File -> New -> Android Project ->
Ceate Project from existing source -> 소스 디렉토리 선택
( -> 그 후엔 그 소스를 Workspace로 복사해서 Import해도 정상 작동됩니다)
출처 : 안드로이드사이드
cmd 명령으로 SDK가 설치된 경로로 이동
C:\develop\android-sdk-windows-1.1_r1\tools\adb
그러면, 도움말이 나온다.
삭제명령은 다음과 같이..
adb uninstall (패키지 이름)
패키지 이름을 모를경우 설치된 패키지명 확인하는 방법
adb shell
#cd /data/data/
#ls
그러면 설치된 패키지 이름을 확인할 수 있음.
C:\develop\android-sdk-windows-1.1_r1\tools\adb
그러면, 도움말이 나온다.
C:\develop\android-sdk-windows-1.1_r1\tools>adb
Android Debug Bridge version 1.0.20
-d - directs command to the only connected USB device
returns an error if more than one USB device is
present.
-e - directs command to the only running emulator.
returns an error if more than one emulator is running.
-s <serial number> - directs command to the USB device or emulator with
the given serial number
-p <product name or path> - simple product name like 'sooner', or
a relative/absolute path to a product
out directory like 'out/target/product/sooner'.
If -p is not specified, the ANDROID_PRODUCT_OUT
environment variable is used, which must
be an absolute path.
devices - list all connected devices
device commands:
adb push <local> <remote> - copy file/dir to device
adb pull <remote> <local> - copy file/dir from device
adb sync [ <directory> ] - copy host->device only if changed
(see 'adb help all')
adb shell - run remote shell interactively
adb shell <command> - run remote shell command
adb emu <command> - run emulator console command
adb logcat [ <filter-spec> ] - View device log
adb forward <local> <remote> - forward socket connections
forward specs are one of:
tcp:<port>
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
adb jdwp - list PIDs of processes hosting a JDWP transport
adb install [-l] [-r] <file> - push this package file to the device and install it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data)
adb uninstall [-k] <package> - remove this app package from the device
('-k' means keep the data and cache directories)
adb bugreport - return all information from the device
that should be included in a bug report.
adb help - show this help message
adb version - show version num
DATAOPTS:
(no option) - don't touch the data partition
-w - wipe the data partition
-d - flash the data partition
scripting:
adb wait-for-device - block until device is online
adb start-server - ensure that there is a server running
adb kill-server - kill the server if it is running
adb get-state - prints: offline | bootloader | device
adb get-serialno - prints: <serial-number>
adb status-window - continuously print device status for a specified device
adb remount - remounts the /system partition on the device read-write
networking:
adb ppp <tty> [parameters] - Run PPP over USB.
Note: you should not automatically start a PDP connection.
<tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
[parameters] - Eg. defaultroute debug dump local notty usepeerdns
adb sync notes: adb sync [ <directory> ]
<localdir> can be interpreted in several ways:
- If <directory> is not specified, both /system and /data partitions will be updated.
- If it is "system" or "data", only the corresponding partition
is updated.
C:\develop\android-sdk-windows-1.1_r1\tools>
Android Debug Bridge version 1.0.20
-d - directs command to the only connected USB device
returns an error if more than one USB device is
present.
-e - directs command to the only running emulator.
returns an error if more than one emulator is running.
-s <serial number> - directs command to the USB device or emulator with
the given serial number
-p <product name or path> - simple product name like 'sooner', or
a relative/absolute path to a product
out directory like 'out/target/product/sooner'.
If -p is not specified, the ANDROID_PRODUCT_OUT
environment variable is used, which must
be an absolute path.
devices - list all connected devices
device commands:
adb push <local> <remote> - copy file/dir to device
adb pull <remote> <local> - copy file/dir from device
adb sync [ <directory> ] - copy host->device only if changed
(see 'adb help all')
adb shell - run remote shell interactively
adb shell <command> - run remote shell command
adb emu <command> - run emulator console command
adb logcat [ <filter-spec> ] - View device log
adb forward <local> <remote> - forward socket connections
forward specs are one of:
tcp:<port>
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
adb jdwp - list PIDs of processes hosting a JDWP transport
adb install [-l] [-r] <file> - push this package file to the device and install it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data)
adb uninstall [-k] <package> - remove this app package from the device
('-k' means keep the data and cache directories)
adb bugreport - return all information from the device
that should be included in a bug report.
adb help - show this help message
adb version - show version num
DATAOPTS:
(no option) - don't touch the data partition
-w - wipe the data partition
-d - flash the data partition
scripting:
adb wait-for-device - block until device is online
adb start-server - ensure that there is a server running
adb kill-server - kill the server if it is running
adb get-state - prints: offline | bootloader | device
adb get-serialno - prints: <serial-number>
adb status-window - continuously print device status for a specified device
adb remount - remounts the /system partition on the device read-write
networking:
adb ppp <tty> [parameters] - Run PPP over USB.
Note: you should not automatically start a PDP connection.
<tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
[parameters] - Eg. defaultroute debug dump local notty usepeerdns
adb sync notes: adb sync [ <directory> ]
<localdir> can be interpreted in several ways:
- If <directory> is not specified, both /system and /data partitions will be updated.
- If it is "system" or "data", only the corresponding partition
is updated.
C:\develop\android-sdk-windows-1.1_r1\tools>
삭제명령은 다음과 같이..
adb uninstall (패키지 이름)
패키지 이름을 모를경우 설치된 패키지명 확인하는 방법
adb shell
#cd /data/data/
#ls
그러면 설치된 패키지 이름을 확인할 수 있음.
Recent Comment