changeset 369:bbf992b0be0d

android (service): set autorestart: with this option, the backend will automatically restart as soon as terminated. This is notably important at the moment to work around a P4A bug which result in a backend killed when frontend is closed (cf. https://github.com/kivy/python-for-android/issues/2053)
author Goffi <goffi@goffi.org>
date Mon, 27 Jan 2020 21:17:08 +0100
parents 7fd138c12506
children 1a12bbd80943
files service/main.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/service/main.py	Mon Jan 27 21:17:08 2020 +0100
+++ b/service/main.py	Mon Jan 27 21:17:08 2020 +0100
@@ -1,5 +1,4 @@
-#!/usr//bin/env python2
-# -*- coding: utf-8 -*-
+#!/usr/bin/env python3
 
 # Cagou: desktop/mobile frontend for Salut à Toi XMPP client
 # Copyright (C) 2016-2018 Jérôme Poisson (goffi@goffi.org)
@@ -37,6 +36,12 @@
 from sat.core import sat_main
 from twisted.internet import reactor
 from twisted.application import app, service
+from jnius import autoclass
+
+
+PythonService = autoclass('org.kivy.android.PythonService')
+PythonService.mService.setAutoRestartService(True)
+
 
 sat = sat_main.SAT()
 application = service.Application("SàT backend")