我使用react-native模块。
我创建了一个扩展服务的 java 类来创建前台通知。 在我的主模块 java 类中,我尝试使用 :
启动服务getReactApplicationContext()
.startService(
new Intent(
getReactApplicationContext(),
ForegroundService.class
)
);
在android文档中它应该调用
@Override
public void onCreate() {
super.onCreate();
}
在我的 ForegroundService 类中。
没有抛出任何错误,所以我相信服务启动时没有任何错误。 但是这个onCreate方法永远不会被调用。 我已经添加了
<service android:name="com.mediarecorder.ForegroundService"/>
。
感谢您的帮助。
我尝试不同的上下文并尝试找到任何解决方案,但没有人适合我的问题。