NotImplementedError:找不到可用的实现!我得到一个错误

问题描述 投票:0回答:0

我正在为 Android 开发一个应用程序。我的应用程序正在使用后台服务。它在后台工作正常,但是当我想用 plyer 发送通知时,“NotImplementedError:找不到可用的实现!”我收到错误消息,后台服务快要死了。如何为 service.py 进行声明。请帮助我

服务.py

 from time import sleep

 from plyer import notification

 from jnius import autoclass


 PythonService=autoclass("org.kivy.android.PythonService")

 PythonService.mService.setAutoRestartService(True)

 if __name__ == '__main__':

    notification.notify(title='BackgroundService Test', 
    message="Notification from android service")

 while True:

    print("Here!!!")

    sleep(5)

main.py

def on_start(self):
    if platform == "android":
        from jnius import autoclass
        SERVICE_NAME = u'{packagename}.Service{servicename}'.format(
            packagename=u'org.kivy.bil',
            servicename=u'Myservice'
        )
        service = autoclass(SERVICE_NAME)
        mActivity = autoclass(u'org.kivy.android.PythonActivity').mActivity
        argument = ''
        service.start(mActivity, argument)

buildozer.spec

 package.name = bil
 package.domain = org.kivy
 requirements = python3,kivy==master,pillow,android,plyer,jnius,
             https://github.com/kivymd/KivyMD/archive/master.zip
 android.permissions=READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE, 
                     POST_NOTIFICATIONS

 services = Myservice:service.py
android service notifications kivy
© www.soinside.com 2019 - 2024. All rights reserved.