어플리케이션을 개발하다 보면 휴대폰 부팅시에 작업해야할 사항들이 생긴다.
그럴때 사용하는게 Broadcast .
해결방법
1. Manifest 에 service를 등록 해줍니다.
<receiver android:name=".service.BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
2. BroadcastReceiver를 상속 받아서 부팅 액션으로 제어하기.
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent){
String action = intent.getAction();
if(action.equalsIgnoreCase("android.intent.action.BOOT_COMPLETED")){
//부팅시 시작할 작업 작성
}
}
}
}
다른 좋은 방법이 있으면 의견 공유해주세요.
'IT개발일지 > Android' 카테고리의 다른 글
[Android] PDF 파일 합치기 merge (0) | 2019.01.21 |
---|---|
[Android] 안드로이드 PDF 파일 열기 (0) | 2019.01.21 |
[Android] PrintHelper 안드로이드 wifi 프린트로 출력하기 (0) | 2019.01.17 |
[Android] Glide 이용하여 RGB 색상채우기 (0) | 2018.12.12 |
[Android] notification 중복 알림 방지 (0) | 2018.11.07 |