Android Question ClassNotFoundException

Discussion in 'Android Questions' started by MitchBu, May 12, 2019.


Similar threads

B4A Code Snippet Version safe notification
B4A Code Snippet Change CheckBox colors
B4A Library Printing and Pdf creation
B4A Code Snippet Change EditText Colors
B4A Code Snippet Workaround the NetworkOnMainThread exception
  1. MitchBu

    MitchBu Active 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
    If photoPrinter.RunMethod("systemSupportsPrint"Null) = True Then
    'FIT = 1, FILL = 2
    "printBitmap"Array("Printer Job Name", _
    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.
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. MitchBu

    MitchBu Active Member Licensed User

    Thank you Erel. I went there and it does seem real nice. I downloaded the zip file, but I don't know what to do with Printing.jar and Printing.xml.

    I tried putting them in the additional libraries folder, but it does not seem to do anything.

    And when I paste the example code in a project, printer is an unknown type.

    Any ideas ?

  4. Erel

    Erel Administrator Staff Member Licensed User

    Go to the libraries tab, right click, choose Refresh. The Printing library should appear. Check it.
  5. MitchBu

    MitchBu Active Member Licensed User

    That was it. The library is now checked.

    And it prints like a charm.

    Thank you Erel :)
    Last edited: May 12, 2019
  6. MitchBu

    MitchBu Active 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.
  7. Erel

    Erel Administrator Staff Member Licensed User

    I need to check it, however you should start a new thread for this as each forum thread should discuss one specific question.
  8. MitchBu

    MitchBu Active Member Licensed User

    Sorry about that. I just started a new thread under the title "Getting and setting the printer resolution".

    Thank you Erel :)
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice