Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support app startup initialization #1063

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: support app startup initialization
  • Loading branch information
fractalwrench committed Jul 16, 2024
commit 28a5c2e7825e55fa9d5e9c0e829d4f156765cce8
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/embrace-defaults.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ android {
}

dependencies {
implementation("androidx.startup:startup-runtime:1.1.1")
implementation("org.jetbrains.kotlin:kotlin-stdlib:${Versions.KOTLIN_EXPOSED}")
add("detektPlugins", "io.gitlab.arturbosch.detekt:detekt-formatting:${Versions.DETEKT}")
add("lintChecks", project.project(":embrace-lint"))
Expand Down
12 changes: 11 additions & 1 deletion embrace-android-sdk/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="https://schemas.android.com/apk/res/android">
<manifest xmlns:android="https://schemas.android.com/apk/res/android"
xmlns:tools="https://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand All @@ -8,5 +9,14 @@
<meta-data
android:name="hostAppId"
android:value="${applicationId}" />
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<meta-data
android:name="io.embrace.android.embracesdk.internal.EmbraceCoreInitializer"
android:value="androidx.startup" />
</provider>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.embrace.android.embracesdk.internal

import android.content.Context
import androidx.startup.Initializer
import io.embrace.android.embracesdk.Embrace

internal class EmbraceCoreInitializer : Initializer<Embrace> {

Check warning on line 7 in embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/EmbraceCoreInitializer.kt

View check run for this annotation

Codecov / codecov/patch

embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/EmbraceCoreInitializer.kt#L7

Added line #L7 was not covered by tests

override fun create(context: Context): Embrace {
val embrace = Embrace.getInstance()
embrace.start(context)
return embrace

Check warning on line 12 in embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/EmbraceCoreInitializer.kt

View check run for this annotation

Codecov / codecov/patch

embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/EmbraceCoreInitializer.kt#L10-L12

Added lines #L10 - L12 were not covered by tests
}

override fun dependencies() = emptyList<Class<out Initializer<*>>>()

Check warning on line 15 in embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/EmbraceCoreInitializer.kt

View check run for this annotation

Codecov / codecov/patch

embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/internal/EmbraceCoreInitializer.kt#L15

Added line #L15 was not covered by tests
}
Loading