run RunOnStartup also on Restart action

This commit is contained in:
Juha Heinanen
2018-06-29 15:34:18 +03:00
parent 0a7a2638d1
commit 88d7635bf8
2 changed files with 8 additions and 3 deletions

View File

@ -108,9 +108,10 @@
android:value="com.tutpro.baresip.MainActivity" />
</activity>
<service android:name=".BaresipService" >
<service android:name=".BaresipService"
android:enabled="true" >
</service>
<receiver
android:enabled="true"
android:exported="true"
@ -118,6 +119,7 @@
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="com.tutpro.baresip.Restart" />
</intent-filter>
</receiver>

View File

@ -4,11 +4,14 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
class RunOnStartup : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.action == Intent.ACTION_BOOT_COMPLETED) {
if ((intent.action == Intent.ACTION_BOOT_COMPLETED) or
(intent.action == "com.tutpro.baresip.Restart")) {
Log.d("Baresip", "Start baresip upon boot completed or restart")
val i = Intent(context, MainActivity::class.java)
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
val b = Bundle()