如何在React Native中调用Java字符串并实时显示
我用java创建了字符串:
import java.lang.Math;
import java.io.*;
import java.util.*;
public class Test {
public int measureConcentration(double[] means){
return (int) ((means[3] / means[1]) * 100) ;
}
public static void main(String[] args) {
int score = measureConcentration(bandMeans);
String ratio = Integer.toString(score);
// Print values
System.out.println(String.valueOf(ratio));
我想在react native中显示它。但当我尝试在powershell中编译应用程序时,由于cannot find symbol int score = measureConcentration(bandMeans);
而收到一个错误
我做错了什么
# 1 楼答案
我遵循React Native docs https://facebook.github.io/react-native/docs/native-modules-android.html#callbacks创建了Android本机模块
及
在应用程序中插入我的包
然后用callback在React Native端获取一个字符串
# 2 楼答案
你试过了吗
然后使用