The APK is written in RAD Studio C++Builder 11.2.
For example, I have tried a lot of methods but I get compile errors.
The code looks like:
UnicodeString command = "test_run";
TFileName fullPath = TPath::Combine(TPath::GetDocumentsPath(), command);
TProcess* process = new TProcess(NULL);
process->Executable = fullPath;
TStreamReader* output = new TStreamReader(process->Output);
process->Execute();
Memo1->Lines->Add(output->ReadLine());
output->Free();
process->Free();
TProcess
doesn't exist in RAD Studio 11.2.
Another way:
#define TArray System::TArray__1
#define TJavaArray TJavaArray__1
#define JString Androidapi::Jni::Javatypes::_di_JString
JString jCommand = StringToJString("test_run");
JString jOutput = StringToJString("");
TArray<System::Byte> *jResult = NULL;
try {
_di_JRuntime rt = TJRuntime::JavaClass->getRuntime();
_di_JProcess proc = rt->exec(jCommand);
_di_JInputStream is = proc->getInputStream();
TJavaArray<System::Byte> *jdata = new TJavaArray<System::Byte>(1024);
while (is->available() > 0) {
int count = is->read(jdata,0,jdata->Length);
jOutput = jOutput + JStringToString(TJString::JavaClass->init(jdata,count));
}
jResult = new TArray<System::Byte>(jdata);
} catch (...) {
ShowMessage("Error: cannot run command");
jOutput = "";
}
Gets stucked in JRuntime
.
I have no idea how to run a console command using the FMX framework.
Can anyone help?