FLAG_INCLUDE_STOPPED_PACKAGES
출처: http://thereclub.tistory.com/15 [아메리카노 공방]
Android] 앱 설치, 삭제, 업데이트 시 서비스(Service) 실행하기
이번 시간에는 ~ 앱이 업데이트 되었을 때 ! 잠금화면 서비스를 재실행하는 방법에 대해서 알아보겠습니다. 이에 추가해서 앱이 설치되었을 때와 삭제되었을 때 Intent를 받는 방법을 알아보겠습니다.
public class PackageReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(action.equals(Intent.ACTION_PACKAGE_ADDED)){
// 앱이 설치되었을 때
} else if(action.equals(Intent.ACTION_PACKAGE_REMOVED)){
// 앱이 삭제되었을 때
} else if(action.equals(Intent.ACTION_PACKAGE_REPLACED)){
// 앱이 업데이트 되었을 때
Intent i = new Intent(context, ScreenService.class);
context.startService(i);
}
}
}
ACTION_PACKAGE_ADDED : 앱이 설치되었을 때
ACTION_PACKAGE_REMOVED : 앱이 삭제되었을 때
ACTION_PACKAGE_RELPLACED : 앱이 업데이트 되었을 때
출처: http://ccdev.tistory.com/29 [초보코딩왕의 Power Dev.]