4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Jetpack ComposeでonResume/onStartに相当する処理を実行する

Posted at

lifecycleのバージョン2.7.0以降で LifecycleEventEffectを使うことができます。

LifecycleEventEffect(Lifecycle.Event.ON_RESUME) {
  // do something here
}
LifecycleEventEffect(Lifecycle.Event.ON_START) {
  // do something here
}

onPause/onStopに相当する処理が必要な場合には、LifecycleResumeEffectもしくはLifecycleStartEffectを使いましょう。

LifecycleResumeEffect {
  // ON_RESUME code is executed here

  onPauseOrDispose {
    // do any needed clean up here
  }
}
LifecycleStartEffect {
  // ON_START code is executed here

  onStopOrDispose {
    // do any needed clean up here
  }
}

参考

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?