Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 보라카이
- UIView
- Bitcode
- swift
- 앱스토어
- 신도림
- 얻는법
- Example
- Xcode
- UITableView
- afterdelay
- loop
- 해몽
- simulator
- 신도림 테크노마트
- LG유플러스
- IOS
- swift3
- 공략
- error
- GCD
- 샘플
- push
- 스마트폰
- 아이폰7
- 포켓몬 GO
- 포켓볼
- setting
- Check
- 페이백
Archives
- Today
- Total
도래울
안드로이드 부팅시 Activity 자동 실행 본문
1.when the OS starts, it will send a Standard Broadcast Action named android.intent.action.BOOT_COMPLETED.
2.construct a class extended from IntentReceiver to catch the action, and override its abstract method onReceiveIntent(Context context, Intent intent), where you can put your start service code in.
3.in AndroidManifest.xml, you should add tag
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
to get the permission of android.intent.action.BOOT_COMPLETED.
In additon, you should add tag
<action android:name="android.intent.action.BOOT_COMPLETED" />
in the <intent-filter> of your IntentReceiver class.
code example:
xml:
Code: |
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission> <receiver android:name=".OlympicsReceiver" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </receiver> |
java:
Code: |
public class OlympicsReceiver extends IntentReceiver { /* the intent source*/ static final String ACTION = "android.intent.action.BOOT_COMPLETED"; public void onReceiveIntent(Context context, Intent intent) { if (intent.getAction().equals(ACTION)) { context.startService(new Intent(context, OlympicsService.class), null); //start my your service here Toast.makeText(context, "OlympicsReminder service has started!", Toast.LENGTH_LONG).show(); } } } |
'개발 > Android' 카테고리의 다른 글
Android drawable-dpi (0) | 2016.02.05 |
---|---|
안드로이드 핸드폰 진동(Vibration) 설정 하기 (0) | 2016.02.05 |
안드로이드 TextSwitcher 사용하기 (0) | 2016.02.05 |
[Android]AndroidManifest.xml 권한 종류 및 설명 (1) | 2016.02.05 |
[Android] Emulator에서 .apk 파일 설치 방법 (0) | 2016.02.05 |
Comments