Android Question ClassNotFoundException


Well-Known Member
Licensed User
I have a working example of printing from a WebView.

I copied it's methods to my app, and made sure to copy the content of #Region ActivityAttributes.

Sub PrintBitmap (mybmp As Bitmap)
   Dim ctxt As JavaObject
   Dim photoPrinter As JavaObject
   photoPrinter.InitializeNewInstance("", Array(ctxt))
   If photoPrinter.RunMethod("systemSupportsPrint", Null) = True Then
     'FIT = 1, FILL = 2
     photoPrinter.RunMethod("setScaleMode", Array(1))
     photoPrinter.RunMethod("printBitmap", Array("Printer Job Name", _
       mybmp, Null))
     Log("Printing not supported.")
   End If
End Sub

Now I get an error in the line photoPrinter.InitializeNewInstance( :

Error occurred on line: 573 (Main)
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(
at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(
at java.lang.reflect.Method.invoke(Native Method)

I am lost. What can I do to make that code work ?

I will appreciate any help.


Well-Known Member
Licensed User
Upvote 0


Well-Known Member
Licensed User
I just experimented with both the older canvas.b4a project that I was referring to in the OP, and the printing library.

Unfortunately, none of them print with sufficient resolution for what I need.

I need a minimum of 600 dpi. At present, I believe the printed resolution is 72 dpi, barely what an antique dot matrix printer from the eighties would do.

I have an app I got in the Play Store that prints at a much higher resolution, so I know it is possible to get much better results.

I found this in the Android Reference that apparently addresses directly my concern :

Taking as example the program that prints using JavaObject, it seems to work somewhat like mediaSize.

Unfortunately, I am not familiar enough with JavaObject to create the code.

And I don't see how this could be applied to the Printer class.

Unless I find a way to print at minimum 600 dpi, this will stop any chance of completing my current project.

I will appreciate any assistance.
Upvote 0