Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
8
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

AppLaunchCheckerでAndroidの初回起動判定

これまでSharedPreferenceで判定していたのですが、AppLaunchCheckerで簡単に制御できたので使ってみました。

参考URL => https://qiita.com/inuko/items/399a4431941dd6b3160b

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_sub)
    val before = AppLaunchChecker.hasStartedFromLauncher(applicationContext)
    AppLaunchChecker.onActivityCreate(this)
    val after = AppLaunchChecker.hasStartedFromLauncher(applicationContext)
}

ちょっとしたハマりポイントになりますが、AppLaunchChecker.onActivityCreate(this)android.intent.category.LAUNCHER のActivityでしか動作しません。
当初奥の階層の画面で初回起動判定の処理が必要だったので、そこで処理後に更新をする予定でしたがうまく行かず・・・

私は AppLaunchChecker.onActivityCreate(this) は最初のActivityで行い、
AppLaunchChecker.hasStartedFromLauncher(applicationContext) の結果はApplicationクラスで保存することで、対応しました

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
8
Help us understand the problem. What are the problem?