Skip to content

Commit

Permalink
service: restart APRSdroid on boot-up
Browse files Browse the repository at this point in the history
  • Loading branch information
ge0rg committed Nov 8, 2017
1 parent 50ce2a5 commit d377bdf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions AndroidManifest.xml
Expand Up @@ -25,6 +25,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE"/>

<application android:label="@string/app_name" android:icon="@drawable/icon"
Expand Down Expand Up @@ -126,5 +127,11 @@
<action android:name="org.aprsdroid.app.SERVICE_STOP" />
</intent-filter>
</service>
<!-- start the service if applicable on boot -->
<receiver android:name=".SystemEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application>
</manifest>
14 changes: 14 additions & 0 deletions src/SystemEventReceiver.scala
@@ -0,0 +1,14 @@
package org.aprsdroid.app

import android.content.{BroadcastReceiver, Context, Intent}

class SystemEventReceiver extends BroadcastReceiver {
val TAG = "APRSdroid.SystemEventReceiver"

override def onReceive(ctx : Context, i : Intent) {
android.util.Log.d(TAG, "onReceive: " + i)
val prefs = new PrefsWrapper(ctx)
if (prefs.getBoolean("service_running", false))
ctx.startService(AprsService.intent(ctx, AprsService.SERVICE))
}
}

0 comments on commit d377bdf

Please sign in to comment.