[현재 접속자 현황]
안드로이드 관련 팁 게시판입니다.
글수 27
기본 UUID = "00000000-0000-1000-8000-00805F9B34FB";
http://blog.naver.com/oh4zzang/40111957130
[1일차]
# 안드로이드 애플리케이션 실습
1. BroadCastReceiver
1) 권한 추가
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
2) MyBootReceiver extends BroadcastReceiver 클래스 작성
3) MyBootReceiver의 onRecive 오버라이딩
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
context.startService(new Intent("android.edu.MySocialService"));
}
4) 매니페스트 등록
<receiver android:name="MyBootReceiver" android:label="MyBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</receiver>
2. Service
1) MySocialService extends Service 클래스 작성
2) onStart 오버라이딩
Toast.makeText(getApplicationContext(), "MySocialService 시작", 2000).show();
NotificationManager ntf = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification noti = new Notification(R.drawable.icon, "친구요청알림", System.currentTimeMillis());
PendingIntent i = PendingIntent.getActivity(MySocialService.this, 0, new Intent("android.edu.MyManager"), 0);
noti.setLatestEventInfo(this, "친구요청알림", "홍길동님의 친구요청", i);
ntf.notify(0, noti);
3) 매니페스트 등록
<service android:name="MySocialService" android:enabled="true">
<intent-filter>
<action android:name="android.edu.MySocialService" />
</intent-filter>
</service>
3. MyManager 액티비티
1) MyManager extends ListActivity
2) 멤버변수 선언
String[] items = {"홍길동", "사또밥", "인디언밥" };
2) onCreate 오버라이딩
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items));
3) onListItemClick 구현
public void onListItemClick(ListView l, View v, int position, long id) {
Toast.makeText(this, items[position], 1000).show();
}
4) MyManager 액티비티 등록
<activity android:name="MyManager" android:label="MyManager">
<intent-filter>
<action android:name="android.edu.MyManager" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
4. 컨텐트프로바이더
ContentValues values = new ContentValues();
values.put(People.NAME, items[position]);
values.put(People.STARRED, 0);
Uri uri = getContentResolver().insert(People.CONTENT_URI, values);

- MySocialService.java (1.2KB)(57)
- AndroidManifest.xml (1.4KB)(38)
- MyBootReceiver.java (600Byte)(34)
- MyManager.java (1.2KB)(48)
- MyGraphExam01.java (3.1KB)(71)
- MyCompas.java (2.7KB)(36)
- day2.zip (473.3KB)(375)
- MyMapMarker.java (3.9KB)(115)
- android_java_20110415.zip (7.9KB)(38)
- android_20110415.zip (288.4KB)(57)
- blutooth.zip (4.1KB)(46)





okgosu
최근 답변 댓글