Skip to content

Commit

Permalink
Start service after update
Browse files Browse the repository at this point in the history
  • Loading branch information
greenart7c3 committed Oct 25, 2024
1 parent 22b5962 commit 6a9e641
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ package com.greenart7c3.citrine.service
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.os.Build

class BootBroadcastReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.action == Intent.ACTION_BOOT_COMPLETED) {
if (intent.action == Intent.ACTION_PACKAGE_REPLACED && Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
val serviceIntent = Intent(context, WebSocketServerService::class.java)
context.startService(serviceIntent)
} else if (intent.action == Intent.ACTION_MY_PACKAGE_REPLACED) {
val serviceIntent = Intent(context, WebSocketServerService::class.java)
context.startService(serviceIntent)
} else if (intent.action == Intent.ACTION_BOOT_COMPLETED) {
val serviceIntent = Intent(context, WebSocketServerService::class.java)
context.startService(serviceIntent)
}
Expand Down

0 comments on commit 6a9e641

Please sign in to comment.