B4A Library ProBundle

Informatix

Expert
Licensed User
Longtime User
In the new version, I added the PDFium library and the OverlayButton.Initialize2 function to OverlayWindow.

PDFium:
It is a fast PDF renderer, written in C, working with any Android version >= 2.3 (Gingerbread). It can open protected PDF (with the password), get the metadata, get the table of contents, get the text of each page, search through the whole document and render the annotations. It includes a navigator.

You can download the APK of the PDFium demo here:
https://drive.google.com/open?id=0B-kneWWcCy7PdHFfa0FxMXNfRzQ
 

shashkiranr

Active Member
Licensed User
Longtime User
Hi Fred,

I tried the demo apk of the pdfviewer. Getting the below error when i go to the second page.
B4X:
main_vvvvvvvv7 (java line: -1)
java.lang.OutOfMemoryError: Failed to allocate a 171740172 byte allocation with 16777216 free bytes and 85MB until OOM
    at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
    at android.graphics.Bitmap.nativeCreate(Native Method)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:975)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:946)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:913)
    at b4a.classes.k.b(Unknown Source)
    at flm.b4a.demopdfium.main._vvvvvvvv7(Unknown Source)
    at flm.b4a.demopdfium.main._vvvvvvvv5(Unknown Source)
    at flm.b4a.demopdfium.main._pdf_afterjump(Unknown Source)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
    at anywheresoftware.b4a.BA.raiseEvent(Unknown Source)
    at b4a.classes.C.a(Unknown Source)
    at flm.b4a.demopdfium.main._buttonnext_click(Unknown Source)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
    at anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
    at anywheresoftware.b4a.BA.raiseEvent(Unknown Source)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(Unknown Source)
    at android.view.View.performClick(View.java:5702)
    at android.widget.TextView.performClick(TextView.java:10888)

Best,
SK
 

Informatix

Expert
Licensed User
Longtime User
As you can read in your error message, it's due to a lack of memory. My viewer in the demo is very rudimentary and does not try to save as much memory as possible (a quick solution could be to set a LargeHeap in the manifest or to reduce the size of rendered bitmaps).
Note that I use a Webview as the main component because it's very convenient to do a quick demo, but it's not what I would choose for a real bitmap viewer.
 

ilan

Expert
Licensed User
Longtime User
hi, i just read the explanation of the libs that are included.
i am used to have a much more detailed explanation from you but this time u choosed to make it short

so i will ask a few questions:

about ClassLoader v1.0
so what i have understood is that i can put a piece of code for example to a txt file and then in a button_click event i can load that code and the button will perform it?
have i understood correctly or am i completely wrong? because if that is possible then this would be amazing, i could update my code without to have to upload a new build (apk) i can just download from a server the new code and use it.


CallSubExtended v2.0
run a sub in a different thread to parallelize execution

can you please give an example how that could be useful?

Error Detection + source v1.2
This library converts the OutOfMemory error and StackOverflow error to RuntimeException for a given sub, allowing to catch them. It can also detect when the UI is frozen before an ApplicationNotResponding error is thrown.

so that mean that i could catch the outofmemory and avoid a crash? or when the application stop responding i could quickly send some information about the error ?

OverlayWindow + source v1.1
are those windows that i have outside the app on the screen? and that i could move them around? something like this: https://www.b4x.com/android/forum/threads/cam-fun-work-in-progress.70265/

thanks and sorry for all those questions
 

Informatix

Expert
Licensed User
Longtime User
Try the examples. That will show you some concrete uses.
ClassLoader is not at all an interpreter or compiler, just a loader of JAR (or uninstalled APK) at runtime. For example, you can download a JAR file (e.g. a B4A library) from your server and run it dynamically. To interpret code at runtime, you should use the BasicLibIDE library instead. You will find it in the ProtectMyApp zip.
CallSubExtended is useful anytime you need to parallelize an execution (for example, you want to compute a GPS path while the UI is still responsive) and is simpler to use than the Threading lib.
ErrorDetection can trap OutOfMemory and, yes, avoid a crash.
 

ilan

Expert
Licensed User
Longtime User
Try the examples. That will show you some concrete uses.

i would like to but the only file i see in post#1 is ProBundleHelp that contains some html files.

CallSubExtended is useful anytime you need to parallelize an execution (for example, you want to compute a GPS path while the UI is still responsive) and is simpler to use than the Threading lib.

so it is something like a service?

thanks
 

DonManfred

Expert
Licensed User
Longtime User
so it is something like a service?
I think it is more an alternative to the threading-lib which is hard to work with.
You call a sub, the sub in running in a new Thread (like threading lib) not blocking your ui and you maybe get an event when the sub is finished (don´t know exactly as i did not try the sample).
 

ilan

Expert
Licensed User
Longtime User

i have no experience with the threading lib but to know that you can run a task in background is good.
like this i could run a loop and show progressdialogshow what is not possible now because the progressdialog freezes until the loop is finished (something that i never understood, the whole point of a progressidalog is to give the user the filling that the app is working and that it is not stuck but if the progressdialog freezes until the loop is finish then there is no point to show it)
 

DonManfred

Expert
Licensed User
Longtime User
here is no point to show it
you can simply use one of the nice loadingviews and show them before you call the sub (with the probundle-lib) and when finished you hide the loadingview...
Or you can use a timer to control another loadingview while the sub is running...
 

Informatix

Expert
Licensed User
Longtime User
i would like to but the only file i see in post#1 is ProBundleHelp that contains some html files.
Oh sorry, I considered you as a lib owner.

so it is something like a service?
No. You just call any sub of your app with the library and it is run in another thread, instead of the UI thread. In an example, I show that you can do a heavy computation in the background while you draw something on screen. In a second example, I show that you can halve the time needed to fill two arrays by filling them simultaneously.
 

DonManfred

Expert
Licensed User
Longtime User
Cookies are required to use this site. You must accept them to continue using the site. Learn more…