Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I start an android activity from a .cpp script?

Tags:

c++

c

android

Say I am using C and C++ and I want to execute a script made in C from within a terminal emulator in android so that it opens an activity, a GUI. Is it possible? and how do I do it?

I wouldn't care using assembly, my tablet's processor is ARMv7. if the answer is somewhere in there.

like image 371
MrFunky Avatar asked Apr 24 '26 17:04

MrFunky


1 Answers

You start an Android Activity that same way you would in Java, by constructing an appropriate Intent instance and then calling Context.startActivity(). The main difference is that you need to thunk into Java via JNI in order to do so from C or C++.

Look into functions like GetMethodID and CallVoidMethod within the JNIEnv class—using those, you can call a Java function from C++ code. Then you just need a small amount of Java glue code to do what you want.

like image 142
Adam Rosenfield Avatar answered Apr 26 '26 05:04

Adam Rosenfield



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!