출처 : http://androidgps.blogspot.com/2008/09/starting-android-service-at-boot-time.html
1. 브로드케스트 리시버
public class LocationLoggerServiceManager extends BroadcastReceiver { public static final String TAG = "LocationLoggerServiceManager"; @Override public void onReceive(Context context, Intent intent) { // just make sure we are getting the right intent (better safe than sorry) if( "android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) { ComponentName comp = new ComponentName(context.getPackageName(), LocationLoggerService.class.getName()); ComponentName service = context.startService(new Intent().setComponent(comp)); if (null == service){ // something really wrong here Log.e(TAG, "Could not start service " + comp.toString()); } } else { Log.e(TAG, "Received unexpected intent " + intent.toString()); } } }
2. 메니페스트 인텐트필터
3. user permission
'3장. 공부 > 3-1. 안드로이드' 카테고리의 다른 글
[Android] TCP/IP로 연결하여 디버깅하는 방법 (0) | 2012.03.19 |
---|---|
[Android] 디바이스 회전시 변수값, 쓰레드 유지하기 (0) | 2010.10.27 |
[Android] 부팅 시점에 서비스 시작 (0) | 2010.09.06 |
[Android] EditText Enter or Done Key Event (0) | 2010.08.09 |
[Android] GPS 상태 체크 및 GPS 설정 호출 (0) | 2010.08.06 |
[Android] Custom Dialog 만들기 (0) | 2010.07.28 |