Java Question Passing context into Library

pdmccann

Member
Licensed User
Longtime User
I am brand new to B4A. I have an Android library that seems to work and a plain old Java library. I would like to create a library that works for a customer that uses B4A as their development platform.

To see if my library can work I also have written a test harness to use the library.

My library takes an android.content.Context for initialization. I have seen reference to BA and context but cannot seem to create or reference these objects in my B4A code.

I have looked for a while and am still puzzled as to how to set this in my library object that I create in my test harness. Any help would be greatly appreciated.

Doug
 

barx

Well-Known Member
Licensed User
Longtime User
Try adding BA as a parameter. i.e.

B4X:
public void MyMethod(BA ba, [I]any other parameters[/I])

And then in the code for the method use

B4X:
ba.context

p.s. I'm no pro at this so I may be wrong.
 

pdmccann

Member
Licensed User
Longtime User
Context question was not clear

Thanks for your response.

I can find BA in the Eclipse/Java project with auto complete. I was wondering how to pass it from the Basic4Android project. Something like

Dim xyz As ClientAction

then

xyz.Initialize([Context reference])
 

barx

Well-Known Member
Licensed User
Longtime User
You don't have to. The BA object is passed automatically.
 

pdmccann

Member
Licensed User
Longtime User
Puzzling passage

IN the Creating libraries tutorial, I found this:

BA - BA is a special object that you can use to raise events and to get access to the user activity, application context and other resources.
The compiler is responsible for passing this object. The IDE doesn't expose it.


Does this mean I use it in the java program and would simply omit it when I call a library method?
 

barx

Well-Known Member
Licensed User
Longtime User
Yes that is correct.

Your Welcome
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…