티스토리 뷰
Pending(보류) intent?
외부 애플리케이션에 내 권한을 허가해서 전달하는 intent.
Intent 를 하나 생성한 후, 특정 시점에 다른 component 들이 pending intent 를 사용하여 다른 component 에게 작업을 요청한다.
예를 들어, 인터넷에서 음악을 다운로드 할 때 notification 에 다운로드 완료를 알리고 해당 알림을 클릭하면 다운로드가 완료된 음악 재생 activity 가 실행되는 것이 여기에 해당.
- 사용자가 Notification 으로 작업을 수행할 때 인텐트가 실행되도록 선언(Android 시스템의 NotificationManager가 인텐트를 실행).
- 사용자가 AppWidget 으로 작업을 수행할 때 인텐트가 실행되도록 선언(홈 스크린이 인텐트를 실행).
- 향후 지정된 시간에 인텐트가 실행되도록 선언(Android 시스템의 AlarmManager가 Intent를 실행).
Intent 생성
PendingIntent.getActivity(Context context, int requestCode, Intent intent, int flags);
|
◼ Type
- PendingIntent.getActivity(Context, int, Intent, int) : Activity를 시작하는 Intent 생성
- PendingIntent.getService(Context, int, Intent, int) : Service를 시작하는 Intent 생성
- PendingIntent.getBroadcast(Context, int, Intent, int) : BroadcastReceiver를 시작하는 Intent 생성
◼ Parameters
- context : context 정보
- requestCode : Pending intent 를 가져올 때 구분하기 위한 id
- intent : 실행시키고 싶은 intent
- flag
Flag | Description |
FLAG_CANCEL_CURRENT | 이전에 생성한 PendingIntent 는 취소하고 새로 만듬 |
FLAG_NO_CREATE | 이미 생성된 PendingIntent 가 없다면 null return. 생성된 PendingIntent 가 있다면 해당 intent 반환 (재사용) |
FLAG_ONE_SHOT | 한번만 사용 (일회용) |
FLAG_UPDATE_CURRENT | 이미 생성된 PendingIntent 가 존재하면 해당 intnet 의 extra data 만 변경 |
Code
1. MainActivity
2. NotiActivity
위 예제는 하단 link 에서 확인할 수 있다.
https://github.com/parkho79/PendingIntentSample
'Android > Intent' 카테고리의 다른 글
Intent 이미지 이동 (0) | 2019.03.20 |
---|---|
Intent extras size limit (0) | 2019.03.20 |
Intent (3) - Implicit(암시적) intent (0) | 2019.02.19 |
Intent (2) - Explicit(명시적) intent (2) | 2019.02.19 |
Intent (1) (0) | 2019.02.18 |
- Total
- Today
- Yesterday
- StringUtils
- registerForContextMenu
- android activity flag
- p2e
- 안드로이드 인텐트
- 무료채굴
- onCreateContextMenu
- android flag activity
- 리워드 어플
- task
- bindservice
- 앱테크 추천
- Android Service
- Intent
- 채굴앱
- StartService
- notifyDataSetChanged
- mPANDO
- RoomDatabase
- android intent
- task 생성
- BroadcastReceiver
- M2E
- 리워드앱
- 안드로이드 서비스
- onContextItemSelected
- android task
- 무료 채굴
- WEMIX
- 앱테크
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |