kopia lustrzana https://github.com/ge0rg/aprsdroid
service: restart APRSdroid on boot-up
rodzic
50ce2a5125
commit
d377bdfa5f
|
@ -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>
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue