Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Android Wake Lock with C++ builder xe6

ZvZvZvZv Member Posts: 2

I'm new to C++ Builder and I can't find how to set WakeLock on Android.
I have experience with Delphi and I know how to set WakeLock with delphi, but I need some guide on that with c++ builder xe6.




  • ZvZvZvZv Member Posts: 2

    Ok, So after a few weeks on this one, here is what I found (and now it works).

    The first thing is that I couldn't locate the Androidapi.JNI.PowerManager C++ files to include in the project, (I just tried to find a C++ parallel to the Delphi Androidapi.JNI.PowerManager.pas) but there was no such file on my computer, after a long net search I found this demo code for Google Glass, and it included Androidapi.JNI.PowerManager.hpp and Androidapi.JNI.PowerManager.o files from here: Samples/Google Glass/

    I included the PowerManager in my source and now the IDE auto-complete feature recognized AcquireWakeLock and ReleaseWakeLock, but...

    When trying to compile the source it failed with this error:
    [ldandroid Error] C:\Users\Public\Documents\Embarcadero\Studio\14.0\PlatformSDKs\android-ndk-r9c\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-ld.exe: .\Android\Release\frmMain.o: in function TForm1::FormCreate(System::TObject*):.\Android\Release\frmMain.o.ll(.text._ZN6TForm110FormCreateEPN6System7TObjectE+0x12): error: undefined reference to 'Androidapi::Jni::Powermanager::AcquireWakeLock()'

    Someone suggested to update the Android SDK from the SDK Tool, so I did but now the IDE couldn't find the ZipAlign.exe, and after some more net search I found that Google changed the default location of ZipAlign.exe, I fixed the default path in the IDE SDK options.

    Now whit the new and updated SDK I tried again, but it didn't help and the compilation failed again on the same undefined reference...

    Again a network search lead to the following post:

    So I added the Androidapi.JNI.PowerManager.o directly from the IDE menu and... yes ! that solved all the issues and even the WakeLock is working on the Android device.

Sign In or Register to comment.