mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor(service): Simplify boot-time service startup (#3730)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
f84747cea6
commit
bdf9dc375b
2 changed files with 9 additions and 41 deletions
|
|
@ -21,13 +21,18 @@ import android.content.BroadcastReceiver
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
||||
/** This receiver starts the MeshService on boot if a device was previously connected. */
|
||||
class BootCompleteReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(mContext: Context, intent: Intent) {
|
||||
// Verify the intent action
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (Intent.ACTION_BOOT_COMPLETED != intent.action) {
|
||||
return
|
||||
}
|
||||
// start listening for bluetooth messages from our device
|
||||
MeshService.startServiceLater(mContext)
|
||||
val prefs = context.getSharedPreferences("mesh-prefs", Context.MODE_PRIVATE)
|
||||
if (!prefs.contains("device_address")) {
|
||||
return
|
||||
}
|
||||
|
||||
MeshService.startService(context)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue