[Tutorial Wish] Wrapping a Android Java class to b4a library

[Tutorial Wish] Wrapping a Android Java class to b4a library


  • Total voters
    44

salmander

Active Member
Licensed User
Longtime User
Looking for a step by step tutorial for wrapping an Android Java class to B4A library.
I know there is a tutorial for making a b4a library, but, what I am asking for is creating a b4a library from a Android Java class.

Please.
 

bloxa69

Active Member
Licensed User
Longtime User
I vote for that too. A sample and tutorial would be very helpful. All this Java stuff makes my head spin:sign0163:
 

bloxa69

Active Member
Licensed User
Longtime User
Erel,
I got basic Java knowledge, and a simple tutorial for a simple library would be very helpful as a starter. I would never bother with Java, but I badly need a wrapper for GLWallpaperService lib which is not available for b4a. I need to develope a lot of live wallpapers, even though most programmers don't take them seriously. I can do them in Eclipse and Java no problem, it is not that complicated, but I got a lot of stuff in b4a that has to be incorporated in every app I make. So, at this point I might face exporting my b4a stuff as .jar or .java files and going back to Java, which sucks as I don't like that language and it's very time consuming to develope in Eclipse.
My main reason when buying B4A was live wallpaper library and widgets library. I also really value B4A community and excellent support. Too bad the basic canvas live wallpapers on Android cannot be HW accelerated and LWP performance using existing b4a library doesn't cut it for me, it's just not smooth enough and draws too much resources. So I must use this GLWallpaperService library or anything that can HW accelerate my LWPs.
I understand it's a complicated matter, but I have no choice but try to wrap some Java lib that will do it for me. I like B4A and would prefer to stay within it. Just need a library that will make HW accelerated LWP possible, 2D is fine (for now).
By the way, any suggestions in that regard will be greatly appreciated.
 

salmander

Active Member
Licensed User
Longtime User
The problem is that except for very simple libraries, you will need to know some Java in order to create a good wrapper.
Little knowledge of Java is not a problem, and practise makes perfect. But, it would be nice to have a tutorial which shows step by step instructions of Simple Java class to B4A library, just something that will give a good start. Then, it will be upto users to practise and develop building more complicated libraries.
 

bloxa69

Active Member
Licensed User
Longtime User
Wrapping GLWallpaperService library is quite difficult
I bet it is though I don't have a choice. How about extending let's say GLSurfaceView for LWP? Seems easy in Java (forgive me my ignorance :sign0148:), and there is B4A OpenGL Lib that provides GLSurfaceView. As far as I understand, all we need is to do this:

Instead, we override getHolder() to call [WallpaperService.Engine].getSurfaceHolder() to get the surface that’s associated with the live wallpaper.

here is Java code I found (at How to Use OpenGL ES 2 in an Android Live Wallpaper | Learn OpenGL ES)

B4X:
class WallpaperGLSurfaceView extends GLSurfaceView {
    private static final String TAG = "WallpaperGLSurfaceView";
 
    WallpaperGLSurfaceView(Context context) {
        super(context);
    }
 
    @Override
    public SurfaceHolder getHolder() {
        return getSurfaceHolder();
    }
 
    public void onDestroy() {
        super.onDetachedFromWindow();
    }
}

Really need that HW acceleration for LWP. I am stuck and cannot publish any of my apps because they all must have an accompanying LWP and current Canvas LWP Lib in B4A just doesn't work for me - to slow, jerky and a resource hog. No anti-aliasing too.
 

Theera

Well-Known Member
Licensed User
Longtime User
For This thread,I give 7 stars.I'm too,I need to learn Java for B4A's library,I don't need to learn java for android. I love B4A,but I don't love Java. I think Pebble's Example is appropriate for study about how to create the library via SLC because it has many import packages.




appropriate
appropriate
 

John.E

Member
Licensed User
Longtime User
Seconded, third and even forth'd (but not the RPN code flavour). A step by step tutorial would be of great assistance.
 

metzeller_2013

Member
Licensed User
Longtime User
Yes please would be much of a great help, trying to wrap datecs sdk here... but i cannot understand how it works, Help please.
 
Top