Lecture/Android/Samsung (2015.8)

Retired DISLab
< Lecture | Android
Swpark (토론 | 기여) 사용자의 2015년 8월 7일 (금) 08:13 버전
(비교) ← 이전 판 | 현재 판 (비교) | 다음 판 → (비교)
이동: 둘러보기, 찾기

목차

소스 코드 교안 다운로드

아래 코드를 다운로드 받아서 코드를 복사하여 실습합니다. 만약 파일이 zip 형태로 받아진다면, 다운로드 후 확장자를 pptx로 변환하면 됩니다.

한글 입력기 설치 방법

  1. HangulKeyboard.zip을 다운로드 받아 압축해제한다.
  2. 에뮬레이터에 설치한다.
C:> adb install HangulKeyboard.apk

개발 도구 다운로드

예제 프로그램 다운로드

Android 개념 및 개발 환경

II-2. 개발 환경 구축과 샘플 프로그램

II-4. Android 개발 도구

  • Ex-Notepad) TraceView - 도구 사용법을 익히기 위하여 설치하는 프로그램. 실행하면 데이터베이스가 만들어진다.

II-5. Activity

II-6. User Interface - Layout & Menu

II-7. Activity

User Interface, Intent와 Broadcast Receiver

III-1. User Interface - Dialog

III-2. View

III-3. User Interface - Resource

III-5. Intent & Adapter 연습

III-8. Service - IPC

데이터 저장, Telephony, Notification & Graphics

IV-1. Preference & File

IV-2. Database

IV-4. Network & Web

Element entry = (Element) nl.item(i);
Element title = (Element) entry.getElementsByTagName("title").item(0);
Element g = (Element) entry.getElementsByTagName("georss:point").item(0);
Element when = (Element) entry.getElementsByTagName("updated").item(0);
Element link = (Element) entry.getElementsByTagName("link").item(0);
 
// Ex-Earthquake-1 수정
// XML 데이터에 오류가 있어 위의 각 항목이 null일 경우 무시한다.
if (entry == null || title == null || g == null || when == null || link == null)
	continue;
 
// . . .
 
// 원래 ss'Z' 였으나 ss.sss'Z'로 변경
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.sss'Z'");
 
// . . .
 
// 진도가 소숫점 이하 짤리는 버그 수정
String magnitudeString = details.split(" ")[1];
double magnitude = Double.parseDouble(magnitudeString);
 
// 원래 분리자가 , 였으나 - 로 변경
details = details.split("-")[1].trim();

IV-5. Telephony, Notification & Alarm

IV-6. Graphics

IV-7. Media Framework

IV-8. Sensors

위치기반 서비스 & Field Application

V-1. 위치기반서비스 - GPS


  • 아래와 같이 AndroidManifest.xml을 수정해야 함.
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" />
 
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
 
<application android:allowBackup="true" 
             android:icon="@drawable/ic_launcher"
             android:label="@string/app_name" android:theme="@style/AppTheme" >
    <meta-data android:name="com.google.android.gms.version" 
             android:value="@integer/google_play_services_version" />
  • import 문을 아래와 같이 해야 함
import com.google.android.gms.commom.ConnectionResult;
import com.google.android.gms.commom.GooglePlayServicesClient.ConnectionCallbacks;
import com.google.android.gms.commom.GooglePlayServicesClient.OnConnectionFailedListener;

V-2. Map

  • 첨기연에서는 proxy 설정을 해야 API KEY를 구하는 사이트에 접근할 수 있다.
    1. 프록시 설정 파일 (인증서자동설치)를 다운로드 후 관리자 모드로 실행한다.
    2. https://code.google.com/apis/console
      • APIs : activation
      • Credentials - Create New Key - Android Key ; API Key 얻음

V-4. Preference

V-5. Content Provider를 통한 지진 데이터 공유

private Handler handler = new Handler();
 
private void refreshEarthquakes() {
	Thread updateThread = new Thread(null, backgroundRefresh, "refresh_earthquake");
	updateThread.start();
}
 
private Runnable backgroundRefresh = new Runnable() {
	public void run() {
		doRefreshEarthquakes();
	}
};
 
private void doRefreshEarthquakes() {
	// 원래의 refreshEarthquakes 메소드
}
 
Runnable notify = new Runnable() {
	public void run() {
		aa.notifyDataSetChanged();
	}
};
 
private void addQuakeToArray(Quake _quake) {
	if (_quake.getMagnitude() > minimumMagnitude) {
		// 새 지진을 우리의 지진 리스트에 추가한다.
		earthquakes.add(_quake);
 
		// 배열 어댑터에 변경을 통지한다.
		handler.post(notify);
	}
}

V-6. Map & Service

<source lang="xml"> 
<application android:icon="@drawable/icon" android:label="@string/app_name">
	<meta-data android:value="AIzaSyDy4abz4WUBVyOqKMpd-3CGymc0xZk5knM" android:name="com.google.android.maps.v2.API_KEY"/>
	<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
 
아래 것은 제거해도 된다.
<permission android:name ="com.example.locations.permission.MAPS_RECEIVE" android:protectionLevel="signature"></permission>


  • p.859 : earthquakeCursor 값 설정이 누락되었으므로 추가할 것
@Override
public void onCreate(Bundle icicle) {
	super.onCreate(icicle);
	setContentView(R.layout.earthquake_map);
 
	earthquakeCursor = getContentResolver().query(EarthquakeProvider.CONTENT_URI, null, null, null, null);
 
	if (earthquakeMap == null) {
		earthquakeMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
	}
 
	addEarthquakeMakerToMap();
}
  • p.860 : LatLng에 인자가 잘못 들어감
double lat = (double) earthquakeCursor.getFloat(EarthquakeProvider.LATITUDE_COLUMN);
double lng = (double) earthquakeCursor.getFloat(EarthquakeProvider.LONGITUDE_COLUMN);
 
float magnitude = earthquakeCursor.getFloat(EarthquakeProvider.MAGNITUDE_COLUMN);
long date = earthquakeCursor.getLong(EarthquakeProvider.DATE_COLUMN);
 
LatLng geoPoint = new LatLng(lat, lng);
개인 도구
이름공간
변수
행위
둘러보기
구성원
연구
연구실
기타
도구모음
인쇄/내보내기