Android Example Various Utilities created with Inline Java Code

Johan Schoeman

Expert
Licensed User
Longtime User
I have added method ReadCPUinfo to class InfoUtilities. It reports a super long string of memory info to the log (returned as one looooonnnng string)
 

Attachments

  • VariousUtilities.zip
    213.1 KB · Views: 489

Johan Schoeman

Expert
Licensed User
Longtime User
Have added Class AESCryptUtilities that comes from here.

".......Simple API to perform AES encryption on Android. This is the Android counterpart to the AESCrypt library Ruby and Obj-C (with the same defaults) created by Gurpartap Singh. https://github.com/Gurpartap/aescrypt......"
 

Attachments

  • VariousUtilities.zip
    215.5 KB · Views: 733

incendio

Well-Known Member
Licensed User
Longtime User
Thanks for sharing.

Should i downloaded all variousutilities.zip files to get all utilities, or there is a latest single file that included all utilities?
 

Johan Schoeman

Expert
Licensed User
Longtime User
Thanks for sharing.

Should i downloaded all variousutilities.zip files to get all utilities, or there is a latest single file that included all utilities?
The last one that I have posted have all the utilities included in different B4A classes.
 

cimperia

Active Member
Licensed User
Longtime User
@Johan Schoeman , I was having a look at your libraries and more specifically to the Date library as I needed to do some work on dates myself.

I have noticed that whenever no parameter is required for a method, you have actually added one : dummy.
Example:
B4X:
Public Sub now() As Int()
  Dim dateAndTime(11) As Int
  Dim dummy As Int = 1
  dateAndTime = nativeMe.RunMethod("now",Array(dummy))
  Return dateAndTime
End Sub

#If Java
  public int[] now(int dummy) {
    values = new int[11];
    Calendar calendar = new GregorianCalendar();
    '.....
  }
#End If
I understand that you did that because the RunMethod requires a second argument which is an array for the java method parameters. However it's not necessary and it "pollutes" both BA and java methods:

B4X:
Public Sub now() As Int()
  Dim dateAndTime(11) As Int
  Dim dummy As Int = 1
  dateAndTime = nativeMe.RunMethod("now", Null)
  Return dateAndTime
End Sub

#If Java
  public int[] now() {
    values = new int[11];
    Calendar calendar = new GregorianCalendar();
    '.....
  }
#End If

It should be easy to fix as a global search/replace would do the trick.
Thanks again for sharing your work.
 

MikeSW17

Active Member
Licensed User
Longtime User
Hi. Just looking at your Utilities, I expect they will be highly useful, Thanks.

There is a bug, when I tried to compile, I got the error:

B4X:
Error compiling program.
Error description: Current declaration does not match previous one.
Make sure to declare the variable before it is used in a For loop.
Error occurred on line: 258
    Dim i As Int

It looks like 'i' needs to be Dim'd before the first use of 'i' earlier in VariousUtilities.b4a.
I'm guessing it should be Dim'd as an Int near the start (which clears the error), but I haven't studied the code in any detail (yet) to see if that's too simple!
 

Johan Schoeman

Expert
Licensed User
Longtime User
Yes, replace code with something like this:
B4X:
    Dim inputString As String = "1001"
    Dim ii As Int
    ii = msu.stringToInt(inputString)
    Log(ii)

Might also have to change "250" to some bigger number (eg 500) in class module InfoUtilities...
B4X:
public String[] deviceInfo(int dummy) {
  String[] mInfo = new String[500]         // was 250 before;
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…