Skip to content

Commit

Permalink
feat: 提供捕获快照的服务入口 (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Nov 9, 2023
1 parent df39f35 commit cfaa6e3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@
</intent-filter>
</service>

<service
android:name=".debug.SnapshotActionService"
android:exported="true"
tools:ignore="ExportedService" />

</application>

Expand Down
26 changes: 26 additions & 0 deletions app/src/main/java/li/songe/gkd/debug/SnapshotActionService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package li.songe.gkd.debug

import android.app.Service
import android.content.Intent
import android.os.Binder
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import li.songe.gkd.appScope
import li.songe.gkd.util.launchTry

/**
* https://github.com/gkd-kit/gkd/issues/253
*/
class SnapshotActionService : Service() {
override fun onBind(intent: Intent?): Binder? = null
override fun onCreate() {
super.onCreate()
appScope.launch {
delay(1000)
stopSelf()
}
appScope.launchTry {
SnapshotExt.captureSnapshot()
}
}
}

0 comments on commit cfaa6e3

Please sign in to comment.