无法响应jni功能

时间:2016-04-04 09:48:47

标签: android odroid

我遇到了问题,我没有发现错误, 这是我的MainActivity代码:

public class MainActivity extends Activity {

    private static final String TAG = "odroid_weather";
    private double temp1, temp2, pressure, altitude, humidity, uv;
    private int visible, ir;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.weatherBoardTest();
        TextView tv = new TextView(this);
        tv.setText(Afficher());
        setContentView(tv);
        TextView temp = new TextView(this);
        temp.setText((int) this.getTemperature1());
        setContentView(temp);
    }

    static
    {
        System.loadLibrary("libodroid_weather");
    }

    public double getTemperature1() {
        return temp1;
    }
    public double getTemperature2() {
        return temp2;
    }

    public double getPressure() {
        return pressure;
    }

    public double getHumidity() {
        return humidity;
    }

    public double getAltitude() {
        return altitude;
    }

           public double getUV() {
        return uv;
    }

    public int getVisibleLight() {
        return visible;
    }

    public int getInfrared() {
        return ir;
    }

    private native String Afficher();


    public native void initSerialInterface();

    public native void readData();
    public native void close();
    static
    {
        System.loadLibrary("odroid_weather");
    }
    protected void weatherBoardTest() {
        Log.d(TAG, "testing weather board");
        initSerialInterface();
        readData();
        Log.d(TAG, "temperature1 = "+this.getTemperature1());
        Log.d(TAG, "Now closing file descriptor.");
       ///  close();
        Log.d(TAG, "finished!");
    }

,这是这些本地方法的cpp代码:

extern "C" {
    void  Java_com_example_assus_appweather_MainActivity_initSerialInterface(){
        initSerial();
    }

    void Java_com_example_assus_appweather_MainActivity_close() {
        close(fd);
    }

    void Java_com_example_assus_appweather_MainActivity_readData(JNIEnv* env, jobject thiz) {
        LOGD("readData()");

我无法找到错误的位置:无法回应JNI功能com.assus.appweather.MainActivity

0 个答案:

没有答案