ForegroundService 无法启动 - FMX

问题描述

在较新版本的 android 上,我将 startService 更改为 startForegroundService 但服务无法启动。在清单文件添加了 ForegroundService 权限。

LIntent := TJIntent.Create;
LIntent.setClassName(TAndroidHelper.Activity.getBaseContext,TAndroidHelper.StringToJString('myService'));  
TAndroidHelper.Activity.startForegroundService(LIntent);

在 android 5 上工作正常:

LIntent := TJIntent.Create;
LIntent.setClassName(TAndroidHelper.Activity.getBaseContext,TAndroidHelper.StringToJString('com.embarcadero.services.myService'));
TAndroidHelper.Activity.startService(LIntent);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)