我已将FCM添加到我的应用程序中,但遇到奇怪的行为-import pyodbc
import pandas as pd
#Import the Excel File into the DataFrame
df = pd.read_excel (r'C:\Users\Diego\Documents\1.Laboral\Jas-Ole\Revenue Management\Reservation_stats_REF.xls')
#Connect Python to SQL Server
conn = pyodbc.connect('Driver={SQL Server};''Server=DIEGO\SQLEXPRESS;''Database=Auxiliary;''Trusted_Connection=yes;')
cursor = conn.cursor()
#Delete a Table data in SQL Server using Python
for row in df.itertuples():
cursor.execute('''
DELETE FROM Auxiliary.dbo.Res_statsTEMP
''')
#Insert a Table data in SQL Server using Python
for row in df.itertuples():
cursor.execute('''
INSERT INTO Auxiliary.dbo.Res_statsTEMP
(Confirmation_number,Status,Name,Telephone,Adults,Children,Baby,Start_date,End_date,Stays,
Reservation_date,Property,Covid_payment,Charged_amount,Revenue,Email,Origin,Market_code,
Transport) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
''',
row.Confirmation_number,row.Status,row.Name,row.Telephone, row.Adults,row.Children,
row.Baby,row.Start_date, row.End_date, row.Stays,row.Reservation_date,row.Property,
row.Covid_payment,row.Charged_amount, row.Revenue,row.Email,row.Origin,row.Market_code,
row.Transport)
conn.commit()
cursor.close()
的继承者几乎立即被销毁。
此行为在真实设备(Nexus 5,Android 6.0.1)上可重现,但在模拟器上,一切正常。服务按预期工作,并且不会立即被破坏。
作为一种解决方法,我尝试使用FirebaseMessagingService
继承者的onMessageReceived
方法启动自己的服务。这适用于应用程序处于前台的情况。在这种情况下,我的支持服务将启动并运行。但是,如果该应用被终止,则我的支持服务将无法启动,从Android的角度来看,这可能是预期的行为。
似乎唯一的解决方案是在FirebaseMessagingService
中设置一些标志,并在应用启动时启动一些检查程序服务。其目的是每秒检查一次待处理操作(例如)并进行实际工作。
这样可以涵盖推送出现在应用程序的前台和后台的情况。
存在类似问题 FirebaseMessagingService extended service class destroyed in android 7.1.1 devices
我使用FirebaseMessagingService.onMessageReceived()
任何帮助将不胜感激。
答案 0 :(得分:0)
有类似的问题。在我的情况下,为应用程序禁用电池优化很有帮助。