비비디바비비부
프로그래밍저장소
비비디바비비부
전체 방문자
오늘
어제
  • 프로그래밍 (72)
    • 안드로이드 (5)
      • 잡다한 지식 (40)
      • Compose (2)
      • Design (3)
      • Project (6)
    • 리액트 (4)
      • 프로젝트 (1)
      • 잡다한 지식 (1)
    • 알고리즘 (3)
      • 알고리즘 문제 (3)
    • AI (4)
      • 딥러닝 (4)
    • CS (2)
    • 잡동사니 (2)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
비비디바비비부

프로그래밍저장소

안드로이드 재시작 코드
안드로이드/잡다한 지식

안드로이드 재시작 코드

2022. 10. 5. 09:14

자바

안드로이드 재시작이 필요한 경우 알람 기능을 사용해 재시작.

Intent mStartActivity = new Intent(HomeActivity.this, SplashScreen.class);
int mPendingIntentId = 123456;
PendingIntent mPendingIntent = PendingIntent.getActivity(HomeActivity.this, mPendingIntentId, mStartActivity,
PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager mgr = (AlarmManager) HomeActivity.this.getSystemService(Context.ALARM_SERVICE);
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
System.exit(0);

 

코틀린

        val mStartActivity = Intent(this@HomeActivity, SplashScreen::class.java)
        val mPendingIntentId = 123456
        val mPendingIntent = PendingIntent.getActivity(
            this@HomeActivity, mPendingIntentId, mStartActivity,
            PendingIntent.FLAG_CANCEL_CURRENT
        )
        this@HomeActivity.getSystemService(Context.ALARM_SERVICE)[AlarmManager.RTC, System.currentTimeMillis() + 100] =
            mPendingIntent
        System.exit(0)
저작자표시 비영리 동일조건 (새창열림)

'안드로이드 > 잡다한 지식' 카테고리의 다른 글

안드로이드 구글 플레이 열기  (0) 2022.10.05
안드로이드 핫스팟 켜기  (0) 2022.10.05
안드로이드 Doze 모드 정리  (0) 2022.05.16
구글 22 시작하기 전 정리한 구글 21 Android  (0) 2022.05.15
안드로이드에서 적용해본 템플릿 메소드 패턴  (0) 2022.05.09
    '안드로이드/잡다한 지식' 카테고리의 다른 글
    • 안드로이드 구글 플레이 열기
    • 안드로이드 핫스팟 켜기
    • 안드로이드 Doze 모드 정리
    • 구글 22 시작하기 전 정리한 구글 21 Android
    비비디바비비부
    비비디바비비부
    안드로이드 기술 블로그, 코딩 공부, 프로그래머

    티스토리툴바