Stats: считать запуском каждый выход на передний план
SvxApp.onCreate вызывается один раз на процесс, поэтому при живом фоне повторные открытия не учитывались. Теперь считаем onStart ProcessLifecycleOwner (холодный старт и каждое открытие приложения).
This commit is contained in:
@@ -44,6 +44,7 @@ kotlin {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("ru.rustore.sdk:pushclient:7.4.0")
|
implementation("ru.rustore.sdk:pushclient:7.4.0")
|
||||||
|
implementation("androidx.lifecycle:lifecycle-process:2.7.0")
|
||||||
testImplementation("junit:junit:4.13.2")
|
testImplementation("junit:junit:4.13.2")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import android.app.Application
|
|||||||
import android.app.NotificationChannel
|
import android.app.NotificationChannel
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import androidx.lifecycle.DefaultLifecycleObserver
|
||||||
|
import androidx.lifecycle.LifecycleOwner
|
||||||
|
import androidx.lifecycle.ProcessLifecycleOwner
|
||||||
import ru.rustore.sdk.pushclient.RuStorePushClient
|
import ru.rustore.sdk.pushclient.RuStorePushClient
|
||||||
import ru.ua1zbe.svxremote.prefs.Prefs
|
import ru.ua1zbe.svxremote.prefs.Prefs
|
||||||
|
|
||||||
@@ -17,7 +20,20 @@ class SvxApp : Application() {
|
|||||||
super.onCreate()
|
super.onCreate()
|
||||||
createPushChannel()
|
createPushChannel()
|
||||||
initRuStorePush()
|
initRuStorePush()
|
||||||
StatsReporter.report(this)
|
trackLaunches()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Считаем запуском каждый вывод приложения на передний план (холодный старт
|
||||||
|
* и повторное открытие), а не только создание процесса — иначе при живом
|
||||||
|
* процессе в фоне повторные открытия не учитывались бы.
|
||||||
|
*/
|
||||||
|
private fun trackLaunches() {
|
||||||
|
ProcessLifecycleOwner.get().lifecycle.addObserver(object : DefaultLifecycleObserver {
|
||||||
|
override fun onStart(owner: LifecycleOwner) {
|
||||||
|
StatsReporter.report(this@SvxApp)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createPushChannel() {
|
private fun createPushChannel() {
|
||||||
|
|||||||
Reference in New Issue
Block a user