- fixed restart with null intent

- upgraded gradle version
This commit is contained in:
Juha Heinanen
2018-08-21 21:21:03 +03:00
parent 5ec6047fb1
commit 8a81fc48e0
3 changed files with 13 additions and 4 deletions

View File

@ -140,6 +140,7 @@
<action android:name="com.tutpro.baresip.Restart" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@ -83,11 +83,19 @@ class BaresipService: Service() {
super.onCreate()
}
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
Log.d(LOG_TAG, "Received onStartCommand action ${intent.getAction()}")
val action: String
when (intent.getAction()) {
if (intent == null) {
action = "Start"
Log.d(LOG_TAG, "Received onStartCommand with null intent")
} else {
action = intent.getAction()
Log.d(LOG_TAG, "Received onStartCommand action $action")
}
when (action) {
"Start" -> {
val pm = getSystemService(Context.POWER_SERVICE) as PowerManager