-4

So the title explains everything you need to know... I tried googling for 2 hours but I just cant find a page where it shows you how to do like example I have a code that calculates the screen size in cpp and I want to call it in java to use it(obviously) EDIT: I just have to put the cpp file name or register it in the Android.mk file... My bad still learning CPP android apps

1 Answers1

1

I just had to place the cpp file name in the Android.mk file... This is my first time so sorry... Fixed code: C++

#include <string.h>
#include <jni.h>

extern "C"
{

    JNIEXPORT jint JNICALL Java_net_pixeldroidof_addonedit_MainActivity_getScreenY(JNIEnv* env, jobject thiz)
    {
        int number = 30;
        return number;
    }
}

Java

public native static int getScreenY();
//And you can start calling it(example: getScreenY() will now return the value from the cpp)