Android Buttons

Hey is there a way for OpenFrameworks to interact with Button objects added to the screen? I know how to add them and interact with them from activities but I don’t know how to use the .cpp files to interact with them

Thanks!

yes.

you’ll need to add a JNI interface

like this in ofAppAndroidWindow.cpp

void Java_cc_openframeworks_OFAndroid_okPressed( JNIEnv*  env, jobject  thiz ){
	if(androidApp) androidApp->okPressed();
	bool yes = true;
	ofNotifyEvent(ofxAndroidEvents().okPressed,yes);
}

then make the static native Java call in OFAndroid.java like this

public static native void okPressed();

then define the virtual function in the ofAndroidApp.h class that you implement in your ofApp

virtual void okPressed(){};

its non-trival but not rocket science.