Android Question How to get library version ?

tucano2000

Active Member
Licensed User
Longtime User
I am trying get programatically the library version to SQLCipher. Is possible ?
 

tucano2000

Active Member
Licensed User
Longtime User
Thanks DonManfred

But how B4A IDE does this ? Appears library version in Libraries Manager. It should not be exposed programmatically ?
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
But how B4A IDE does this ?
for example: this is the xml from the youtube library.
See the last lines...

 
Upvote 0

tucano2000

Active Member
Licensed User
Longtime User
Nice. Got it. But an xml file is not visible to my application that uses a determines referenced library. Right ?
 
Upvote 0

tucano2000

Active Member
Licensed User
Longtime User
This gave me an idea. Include own xml or txt with the version in the files directory of my application. Single drawback is that when you change the library version will have to change this file . Should work.
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
Call this inline Java using the usual method:
B4X:
#If JAVA
public static float GetVersion(Object o)
{
    return o.getClass().getAnnotation(anywheresoftware.b4a.BA.Version.class).value();
}

#End If

Beware that there's no Exception catching, here. If the Object you pass as a parameter doesn't have a @Version annotation, it will blow up your app.
 
Upvote 0

tucano2000

Active Member
Licensed User
Longtime User

Thanks Roycefer. What parameter to (Object o). Where I got it ? (Object o) . I need put this in params:

If nativeMe.IsInitialized=False Then nativeMe.InitializeContext
Dim SQLCipherVersion As Float=nativeMe.RunMethod("GetVersion", Params() As Object) '<=== What's params library name here ?

I find this in xml of the library ?
 
Last edited:
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
Whatever Object you want, so long as it has an @Version annotation in its Java code. This will usually be the "central" object of a library. If a library only has one class, then create an instance of that class and use that as the parameter.

I haven't used the SQLCipher library but looking at its documentation, there is only one class and it is the SQLCipher class.
B4X:
Dim sc as SQLCipher
sc.Initialize(blah, blah, blah, blah, ....)
Log("version is: " & nativeMe.RunMethod("GetVersion", Array(sc)))

Untested, beware.
 
Upvote 0

tucano2000

Active Member
Licensed User
Longtime User
I got this error in Log line of my code:



My code:

B4X:
...
 Dim sc As SQLCipher 
    sc.Initialize(File.DirInternal,"xxx.db",True,"dkjfakldfj", "")
    Log("version is: " & nativeMe.RunMethod("GetVersion", Array(sc)))
...

#If JAVA
    public static float GetVersion(Object o)
    {
        return o.getClass().getAnnotation(anywheresoftware.b4a.BA.Version.class).value();
    }
  
#End IF


But the SQLCipher object was initialized.
 
Last edited:
Upvote 0

tucano2000

Active Member
Licensed User
Longtime User
You are right. when I changed the code forgot to do this. Works perfectly !!! Great !!! You are master because in google I don't found this.

now my correct code:

B4X:
    Dim sc As SQLCipher
    sc.Initialize(File.DirInternal,"xxx.db",True,"dkjfakldfj", "")
    nativeMe.InitializeContext
    Log("version is: " & nativeMe.RunMethod("GetVersion", Array(sc)))
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…