Android 无法通过react本机网桥运行服务

Android 无法通过react本机网桥运行服务,android,react-native,Android,React Native,我用Java创建了一个本机模块,负责在后台运行服务 我在ClassA中有这个方法: @ReactMethod public void startService(final Promise promise) { Intent intent = new Intent(getCurrentActivity(), BackgroundService.class); intent.putExtra(BackgroundService.FILENAME, "te

我用Java创建了一个本机模块,负责在后台运行服务

我在
ClassA
中有这个方法:

  @ReactMethod
    public void startService(final Promise promise) {

        Intent intent = new Intent(getCurrentActivity(), BackgroundService.class);
        intent.putExtra(BackgroundService.FILENAME, "test123.html");
        intent.putExtra(BackgroundService.URL,
        "http://www.vogella.com/index.html");

         Activity currentActivity = getCurrentActivity();

         if (currentActivity == null) {
            promise.reject("Activity doesnt exist");
         } else {
            getCurrentActivity().startService(intent);
         }
    }
以下是
BackgroundService
中的代码:

public class BackgroundService extends IntentService {

private int result = Activity.RESULT_CANCELED;
public static final String URL = "urlpath";
public static final String FILENAME = "filename";
public static final String FILEPATH = "filepath";
public static final String RESULT = "result";
public static final String NOTIFICATION = "com.vogella.android.service.receiver";

  public BackgroundService() {
      super("BackgroundService");
  }
  public String getName() {
      return "BackgroundService";
  }

@Override
protected void onHandleIntent(Intent intent) {
    //do stuff
    ClassA.servicePromise.resolve("done with service!");

 }
servicePromise
在classA中的定义如下:
公共静态承诺服务承诺=null

如果我理解正确,问题是
getCurrentActivity.startService(intent)
没有正确执行。在
getCurrentActivity.startService(intent)
之后,我能够在
startService
内成功返回一个承诺,因此我知道问题不在于如何调用
startService
。但是,我无法从内部
后台服务
返回我想要的承诺

onHandleIntent
中,我尝试调用
ClassA.serviceconomise.resolve(“使用服务完成!”)
在我的清单中,我添加了
服务
,如下所示:

  <service android:name="com.smaplePakcage.name.BackgroundService"
        android:exported="false">
     </service>