service: restart APRSdroid on boot-up

pull/227/head
Georg Lukas 2017-11-08 08:26:26 +01:00
rodzic 50ce2a5125
commit d377bdfa5f
2 zmienionych plików z 21 dodań i 0 usunięć

Wyświetl plik

@ -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"
@ -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>

Wyświetl plik

@ -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))
}
}