getCurrentActivity不公开'com.facebook.react.bridge.React Context`无法从外部包访问

Ali*_*Ali 7 android react-native

我正在尝试构建react-native需要传递Activity给某个方法的模块

private ReactApplicationContext reactContext;

...

@ReactMethod
public void sendVerificationCode(String phoneNumber)
{
    PhoneAuthProvider.getInstance().verifyPhoneNumber(
            phoneNumber,                            // Phone number to verify
            60,                                     // Timeout duration
            TimeUnit.SECONDS,                       // Unit of timeout
            reactContext.getCurrentActivity(),      // Activity (for callback binding)
            callback);                              // OnVerificationStateChangedCallbacks

}
Run Code Online (Sandbox Code Playgroud)

我曾经reactContext.getCurrentActivity()从当前的活动中获取,但它告诉我这getCurrentActivity()不是公开的,无法从外部包中访问

getCurrentActivity不公开'com.facebook.react.bridge.React Context`无法从外部包访问

我怎么能得到当前的活动?

完整代码:

public class FirebasePhoneAuth extends ReactContextBaseJavaModule
{
    private ReactApplicationContext reactContext;
    private OnVerificationStateChanged callback;

    public FirebasePhoneAuth(ReactApplicationContext reactContext)
    {
        super(reactContext);
        this.reactContext = reactContext;
    }

    @Override
    public String getName()
    {
        return "FirebasePhoneAuth";
    }

    @ReactMethod
    public void sendVerificationCode(String phoneNumber)
    {
        PhoneAuthProvider.getInstance().verifyPhoneNumber(
                phoneNumber,                            // Phone number to verify
                60,                                     // Timeout duration
                TimeUnit.SECONDS,                       // Unit of timeout
                reactContext.getCurrentActivity(),      // Activity (for callback binding)
                callback);                              // OnVerificationStateChangedCallbacks

    }

}
Run Code Online (Sandbox Code Playgroud)

Ali*_*Ali 1

该类ReactContextBaseJavaModule已经有方法getCurrentActivity()

代码 :

public class FirebasePhoneAuth extends ReactContextBaseJavaModule
{
    ...

    @ReactMethod
    public void sendVerificationCode(String phoneNumber)
    {
        Activity activity = getCurrentActivity();

        PhoneAuthProvider.getInstance().verifyPhoneNumber(
                phoneNumber,
                60,
                TimeUnit.SECONDS,                      
                activity,
                callback);

    }

}
Run Code Online (Sandbox Code Playgroud)