일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 방울토마토 씨부터 키우기
- 어플만들기
- 안방농사
- 괌맛집
- 에어팟충전기
- 스투키
- 신혼여행
- 핫엔드
- 겨울나기
- 방토 농사
- 집에서 방울토마토 키우기
- 방울토마토키우기
- 쿠폰나눔
- 다크나이트
- 보일러절약
- 맥세이프충전기
- 괌 신혼여행
- 괌
- 메이플
- 2in1무선충전기
- Ender 3 V3 KE
- 안드로이드
- 메이플스토리
- 집 방울토마토
- 방울토마토 유기농
- 휴대용무선충전기
- 메이플스토리M
- 다이소 방울토마토
- 다이소 방울토마토키트
- Android
Archives
- Today
- Total
괴도군의 블로그
[android]나의앱에서 다른 어플 설치,삭제,변경 이벤트 받기 본문
반응형
나의 앱에서 다른 앱을 설치하고 삭제하고 업데이트할때 사용하는 구조입니다.
설치, 제거코드는 목록의 다른글을 참조하시고
먼저 BroadcaseReceiver를 상속받는 클래스를 만듭니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | public class ApplicationBroadcast extends BroadcastReceiver { private static final String TAG = "PACKAGE_OBSERVER"; @Override public void onReceive(Context context, Intent intent) { Log.v(TAG, "intent : "+intent); Log.v(TAG, "action : "+intent.getAction()); Log.v(TAG, "data : "+intent.getData()); } } | cs |
AndroidManifest.xml파일에서 코드를 추가합니다
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <receiver android:name=".application.ApplicationBroadcast"> <intent-filter> <action android:name="android.intent.action.PACKAGE_ADDED"/> <action android:name="android.intent.action.PACKAGE_REMOVED"/> <action android:name="android.intent.action.PACKAGE_CHANGED"/> <action android:name="android.intent.action.PACKAGE_REPLACED"/> <action android:name="android.intent.action.PACKAGE_DATA_CLEARED"/> <action android:name="android.intent.action.PACKAGE_FIRST_LAUNCH"/> <action android:name="android.intent.action.PACKAGE_FULLY_REMOVED"/> <action android:name="android.intent.action.PACKAGE_NEEDS_VERIFICATION"/> <action android:name="android.intent.action.PACKAGE_RESTARTED"/> <action android:name="android.intent.action.PACKAGE_VERIFIED"/> <data android:scheme="package"/> </intent-filter> </receiver> | cs |
어플리케이션안에만 넣어주면됩니다.
액티비티안에다 넣지마세요..
위에 액션들을 다 넣어주실 필요는없고 밑에 써놓은 번호에 맞게 넣어주시면 됩니다.
그리고.. 설치 제거코드로 테스트해보시면.. 잘나옵니다. 폰마다 다르겠지만 몇초 걸리는것 같네요
1. 앱 설치시 이벤트
android.intent.action.PACKAGE_ADDED
2.앱 삭제시 이벤트
android.intent.action.PACKAGE_REMOVED
android.intent.action.PACKAGE_FULLY_REMOVED
3.앱 재설치 및 업데이트 이벤트
android.intent.action.PACKAGE_REMOVED
android.intent.action.PACKAGE_REPLACED
android.intent.action.PACKAGE_CHANGED (com.google.android.gms 패키지명이 뜨는걸보니 시스템쪽인듯..)
참고.. ( http://developer.android.com/intl/ko/reference/android/content/Intent.html )
String | ACTION_PACKAGE_ADDED | Broadcast Action: A new application package has been installed on the device. |
String | ACTION_PACKAGE_CHANGED | Broadcast Action: An existing application package has been changed (e.g. |
String | ACTION_PACKAGE_DATA_CLEARED | Broadcast Action: The user has cleared the data of a package. |
String | ACTION_PACKAGE_FIRST_LAUNCH | Broadcast Action: Sent to the installer package of an application when that application is first launched (that is the first time it is moved out of the stopped state). |
String | ACTION_PACKAGE_FULLY_REMOVED | Broadcast Action: An existing application package has been completely removed from the device. |
String | ACTION_PACKAGE_INSTALL | This constant was deprecated in API level 14. This constant has never been used. |
String | ACTION_PACKAGE_NEEDS_VERIFICATION | Broadcast Action: Sent to the system package verifier when a package needs to be verified. |
String | ACTION_PACKAGE_REMOVED | Broadcast Action: An existing application package has been removed from the device. |
String | ACTION_PACKAGE_REPLACED | Broadcast Action: A new version of an application package has been installed, replacing an existing version that was previously installed. |
String | ACTION_PACKAGE_RESTARTED | Broadcast Action: The user has restarted a package, and all of its processes have been killed. |
String | ACTION_PACKAGE_VERIFIED | Broadcast Action: Sent to the system package verifier when a package is verified. |
반응형
'#프로그래밍 > Android' 카테고리의 다른 글
Android Studio Log 출력방법(태그를 빼먹지말자!) (0) | 2015.12.30 |
---|---|
[android]안드로이드 어플 강제 홈키 / 백그라운드 전환 코드 (0) | 2015.12.10 |
[android]앱에서 앱설치,삭제코드 (0) | 2015.12.08 |
[android] inapp 인앱 결제 롤리팝 오류(lollipop) (0) | 2015.08.28 |
[ANDROID] 타이머 설정법 (무한 반복) (0) | 2015.08.07 |
Comments