Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: [JNI] Getting application Activity to JNativeActivity object



Permlink Replies: 1 - Last Post: Aug 18, 2016 11:06 AM Last Post By: Remy Lebeau (Te...
John Stolczyk

Posts: 8
Registered: 9/18/16
[JNI] Getting application Activity to JNativeActivity object
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 18, 2016 6:31 AM
Hello.

Im trying to colorize statusbar in android app.

In Java I was doing it usually like this
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));

But I dont know how to do it in C++ using JNI libraries

Far for I know only MainActivity() and JNativeActivity got getWindow() methods, so I could use

 JWindow *androidWindow = activity->getWindow();


But totally dont know how to get current Activity
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: [JNI] Getting application Activity to JNativeActivity object
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 18, 2016 11:06 AM   in response to: John Stolczyk in response to: John Stolczyk
John wrote:

Far for I know only MainActivity() and JNativeActivity got
getWindow() methods, so I could use

 JWindow *androidWindow = activity->getWindow();

You need to use _di_JWindow instead of JWindow*:

_di_JWindow androidWindow = activity->getWindow();


di types are typedefs of the DelphiInterface template class, which handles
interface reference counting.

But totally dont know how to get current Activity

Use the SharedActivity() function, which returns a _di_JActivity.

Depending on your version of C++Builder (which you did not state), SharedActivity()
is declared in either the FMX.Helpers.Android.hpp or Androidapi.Helpers.hpp
header file.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02