반응형

안드로이드 5

안드로이드 Bluetooth 연결

1. Bluetooth 프로토콜 지원: SDP, HID - Low Power Energy 지원 2. Bluetooth Permission in AndroidManifest.xml 3. BluetoothAdapter를 생성하여 활성화 4. Querying paired devices - 주변 스캔하여 블루트스 장치 주소 확인 5. 3 Threads (Service 형태) 1) AcceptThread: 특정 주소와 UUID로 연결 대기 2) ConnectThread: 폰에서 타 장비로 연결할 경우, 연결 요청 - BluetoothDevice 객체: 수신한 주소, Pairing된 정보 - BluetoothSocket: 해당 장비와 소켓 연결 3) ConnectedThread: 연결 완료 후, 실제 데이터 교환 ..

Android Example Application 개발

1. 안드로이드 프로젝트 생성 - [File]-[New]-[Android Application Project] - Application Name: UI 표시되는 이름 - Project Name: 개발 화면에서 표시되는 이름 - Package Name: 보통 com.example 2. Android Project 구성 - src: package 안의 실제 소스 코드 위치 - gen: 자동 생성된 소스 코드 위치 - res/drawable: 그래픽 이미지 저장 - layout/*.xml: 각 Activity 구성 - AndroidManifest.xml: 기본 어플리케이션 설정 3. Android Layout 구성하기 - Layout/*.xml 선택, Graphical Layout 확인 - 실제 Layout ..

Android 개발환경 설치

Android Open Source Project http://source.android.com Android kernel source 제공 Android Developer Site http://developer.android.com 안드로이드 개발자 사이트 SDK 다운로드 제공 및 어플리케이션 개발에 전반적 정보 제공 Java 기반의 객체 지향 프로그래밍 (OOP: Object-Oriented Programming) Android SDK 설치 Eclipse 기반의 Android Development Tool Plugin 으로 제공 Eclipse + ADT Plugin 같이 제공 기존 Eclipse에 ADT만 제공하여 설정 Android SDK 설치 http://developer.android.com 접..

sendBroadcast() static으로 사용하는 법

static 함수 또는 클래스 내에서는 내부 호출 함수를 static으로 사용하여야 한다. 따라서, sendBroadcast() 함수도 static으로 사용이 필요하다. 이럴 때 방법은 Context를 이용하는 것이다! (단, Context 객체를 받을 수 있는 Activity, Service를 상속하였을 때 사용) 예를 들어, 아래는 당연히 오류가 발생한다.public static void mA(){Intent i;...sendBroadcast(i);} 다음과 같이 Context 객체를 통해 sendBroadcast를 호출한다. public static class A extends Service{ Context context; public A(){context = this; // Service 자체가 ..

Toast로 메시지 띄우기

가장 간단하면서도 유용한 메시지 표시 기능 이다. 실제 화면에 해당 메시지를 표시할 수 있다. 방법은 간단하다. Toast.makeText(this, "넣고자 하는 Text", Toast.LENGTH_LONG).show(); 실제 함수 API는 다음과 같다. makeText(Context context, CharSequence text, int duration) Context context: Text를 표시할 context이다. 따라서, Activity나 Service 등에서 사용이 가능하다. Context 정보를 가지고 있다면, 아무런 제약없이 함수를 사용할 수 있다. (Context에 대해서는 추가 정리 필요) ChartSequence text: 실제 표시할 문자열이다. 주로 String으로 표시할 ..

반응형