Inline Java

susu

Well-Known Member
Licensed User
Will it support external library (.jar file) ? If yes, can I compile it to B4A wrapper?
 

RandomCoder

Well-Known Member
Licensed User
I guess Java should be the next language I learn. I mean that in the broadest of terms, attempt to understand might have been more precise.
 

thedesolatesoul

Expert
Licensed User
Thanks for this.

I guess a B4A class is also coming from a Java class, which has events like onCreate etc? To be honest, there is no point in hooking into class events, but I just wanted to be generic.

I may be complicating things but there are a couple of scenarios I think about:
- There is a possibility of running setTheme in onCreate BEFORE calling super.onCreate and setContentView to change the theme at runtime
- There is a possibility of running onPreparedOptionsMenu AFTER the template code to decontruct and reconstruct the menu
- There is a possiblity of completely overriding events like onPrepareOptions (not a good option, but it means you dont have to deconstruct things)
I know this is for the savy, the slick and the spurious, but hey, you are the sublime!

It works with hooks that I add to the template code.
Can you elaborate on this?
 

thedesolatesoul

Expert
Licensed User
Will it support external library (.jar file) ? If yes, can I compile it to B4A wrapper?
The answer to this is yes.
Add AdditionalJar to the attributes.
You will have to do imports in the inline java. And call methods.
If you write your code in a class you can compile to B4A lib.
But again, it also depends on the complexity of the lib. It will be less typing than Java Object but I think it will offer the same features.
 
Last edited:

KMatle

Expert
Licensed User
My thoughts: It IS very helpful to many developers but hopefully there is not too much Java coding & questions here in the forum the next months or new functions which will be coded only in Java. The main reason for me using B4A is not to use Java. We will see.
 

Erel

Administrator
Staff member
Licensed User
- There is a possibility of running setTheme in onCreate BEFORE calling super.onCreate and setContentView to change the theme at runtime
- There is a possibility of running onPreparedOptionsMenu AFTER the template code to decontruct and reconstruct the menu
- There is a possiblity of completely overriding events like onPrepareOptions (not a good option, but it means you dont have to deconstruct things)
Yes. This is exactly the example in the first post.
You will be able to prevent the standard onPreparedOptionsMenu from running at all and run your code instead (or run both where your code runs first).
 

thedesolatesoul

Expert
Licensed User
Yes. This is exactly the example in the first post.
You will be able to prevent the standard onPreparedOptionsMenu from running at all and run your code instead (or run both where your code runs first).
That is very impressive then.
I just realized that _onCreate runs first then Activity_Create and then Test.
Its a little bit insane and dizzying!
 

Troberg

Well-Known Member
Licensed User
Why "#if Java"? Shouldn't it be something like "#begin Java"? It's not really a test, it's an indication that what is to follow is Java, not B4A.

Or am I just stupid and missing the obvious?
 

Troberg

Well-Known Member
Licensed User
You can say the same thing about #If B4A or #IF B4J.

The inline Java feature is based on the same conditional compilation system.
But, will there ever be a situation when #If Java is false? And, if there is, wouldn't that kind of break the useability of this feature pretty hard?

I can easily see why #If B4A or #If B4J could be false, so there it makes sense, but if we are in a situation where Java is not available, wouldn't that break everything?

Edit: Nevermind. After reading the post on inline ObjectiveC in B4i, I get it. I forgot that we don't always compile to Java...
 
Last edited:

Beja

Expert
Licensed User
Thank you Erel so much, you succeeded in dragging me to java that I always didn't like.. now I can tweet java codes until I learn the language and one day can write entire app with java.
 

moster67

Expert
Licensed User
Thank you Erel so much, you succeeded in dragging me to java that I always didn't like.. now I can tweet java codes until I learn the language and one day can write entire app with java.
Is this ironical?

I think the inline feature will be a great feature. For instance you can implement code-snippets in JAVA directly in your B4a-code without the hassle of writing a wrapper and loosing time. I think the aim of this feature is just to make B4a even more flexible than it is today. If you want to use it, that is up to you.
 
Top