Android statusbar color in Embarcadero RAD Studio, C++

  

EDIT:

I managed to remove current background of status bar (and also accidently background of navigation bar) using this code

ANativeActivity_setWindowFlags(PANativeActivity(System::DelphiActivity),
TJWindowManager_LayoutParams::JavaClass->FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
TJWindowManager_LayoutParams::JavaClass->FLAG_TRANSLUCENT_STATUS);

Still don’t know how to add new background color

This will NOT work

_di_JWindow androidWindow = SharedActivity()->getWindow();
androidWindow->setStatusBarColor(17170432);

=====================================================================

Original post:

I’m trying to colorize status bar of the android app made in FireMonkey/RAD Studio.

To achive it in Java I usually use this code:

Window window = activity.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(activity.getResources().getColor(R.color.my_statusbar_color));

In RAD Studio I’m trying to do it like this
First I’m including Android libs in header

#ifdef __ANDROID__
#include <FMX.Helpers.Android.hpp>
#include <Androidapi.JNIBridge.hpp>
#include <Androidapi.JNI.Os.hpp>
#include <Androidapi.JNI.JavaTypes.hpp>
#include <Androidapi.JNI.GraphicsContentViewText.hpp>
#include <Androidapi.JNI.Util.hpp>
#include <Androidapi.JNI.App.hpp>
#include <Androidapi.JNI.Embarcadero.hpp>
#include <Androidapi.Jni.hpp>
#endif

Then when I’m trying to call:

JWindow androidWindow = JNativeActivity::getWindow();

I’m getting over 100 errors like:

[bccaarm Error] HeaderFooterTemplate.cpp(67): call to non-static member function without an object argument
[bccaarm Error] HeaderFooterTemplate.cpp(67): variable type ‘Androidapi::Jni::Graphicscontentviewtext::JWindow’ is an abstract class
sysmac.h(327): unimplemented pure virtual method ‘QueryInterface’ in ‘JWindow’
sysmac.h(328): unimplemented pure virtual method ‘AddRef’ in ‘JWindow’
sysmac.h(329): unimplemented pure virtual method ‘Release’ in ‘JWindow’
Androidapi.JNI.JavaTypes.hpp(763): unimplemented pure virtual method ‘equals’ in ‘JWindow’
Androidapi.JNI.JavaTypes.hpp(764): unimplemented pure virtual method ‘getClass’ in ‘JWindow’
Androidapi.JNI.JavaTypes.hpp(765): unimplemented pure virtual method ‘hashCode’ in ‘JWindow’
Androidapi.JNI.JavaTypes.hpp(766): unimplemented pure virtual method ‘notify’ in ‘JWindow’
Androidapi.JNI.JavaTypes.hpp(767): unimplemented pure virtual method ‘notifyAll’ in ‘JWindow’
Androidapi.JNI.JavaTypes.hpp(768): unimplemented pure virtual method ‘toString’ in ‘JWindow’
Androidapi.JNI.JavaTypes.hpp(769): unimplemented pure virtual method ‘wait’ in ‘JWindow’
Androidapi.JNI.JavaTypes.hpp(770): unimplemented pure virtual method ‘wait’ in ‘JWindow’
Androidapi.JNI.JavaTypes.hpp(771): unimplemented pure virtual method ‘wait’ in ‘JWindow’
Androidapi.JNI.GraphicsContentViewText.hpp(18831): unimplemented pure virtual method ‘addContentView’ in ‘JWindow’
Androidapi.JNI.GraphicsContentViewText.hpp(18832): unimplemented pure virtual method ‘addFlags’ in ‘JWindow’
Androidapi.JNI.GraphicsContentViewText.hpp(18833): unimplemented pure virtual method ‘clearFlags’ in ‘JWindow’
Androidapi.JNI.GraphicsContentViewText.hpp(18834): unimplemented pure virtual method ‘closeAllPanels’ in ‘JWindow’
Androidapi.JNI.GraphicsContentViewText.hpp(18835): unimplemented pure virtual method ‘closePanel’ in ‘JWindow’
Androidapi.JNI.GraphicsContentViewText.hpp(18836): unimplemented pure virtual method ‘findViewById’ in ‘JWindow’
Androidapi.JNI.GraphicsContentViewText.hpp(18837): unimplemented pure virtual method ‘getAllowEnterTransitionOverlap’ in ‘JWindow’

This are my first steps with C++, so Im not sure I am doing it right.

Comments are closed.