B4A Library SD: BT Printer Bluetooth

kurniahenki

Member
Licensed User
Dear Sir

after i change the target sdk from 26 to 19 , it show the first time install
asking permission for Approximage location (network-based) and granted.

and my version android 6

it still same "Unfortunatelly, Bluetooth Printer Sample has stopped"
 

Star-Dust

Expert
Licensed User
Longtime User
You must not ask for any position.
By tomorrow I am attaching a simple example to try so we understand what happens in your devices.

Have you updated the serial library?

Star-Dust said:
Required: B4A 8+ and Serial Library 1.30+ (here)
 

kurniahenki

Member
Licensed User
i already download serial library from your link , and alread put in my basic4android libaries that used by b4a
and already serial version 1.31

and neither i select it or not select it still when compile to .apk and install and running the apps still same error

"Unfortunatelly, Bluetooth Printer Sample has stopped"

many thanks for your passion sir.

i really hope can start donate and using this library sir.


many thanks.
 

Star-Dust

Expert
Licensed User
Longtime User
You do not have to select the Serial library, and it is important that it is up-to-date
I will give you another example that allows you to understand the error
 

kurniahenki

Member
Licensed User
sorry sir.

but when i showing error message on running release, the error happen when printer.initialize

the weird is when i running on debug mode it's normal no error.


thx
 

Star-Dust

Expert
Licensed User
Longtime User
try to intercept the error with this method
B4X:
    Try
        Printer.Initialize(Me,"Printer",Encoding.Windows1252)
    Catch
        Log("error: " & LastException.Message)
    End Try
 

kurniahenki

Member
Licensed User

Dear Sir

nothing happen and not showing error when release just suddenly message
""Unfortunatelly, Bluetooth Printer Sample has stopped""

for when debuging on logs :

Please update to B4A-Bridge v2.30+
Logger connected to: samsung SM-P355-359896061311831
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:21)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:349)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:454)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:148)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at b4a.example.main._activity_create(main.java:353)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6823)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)
Caused by: java.lang.RuntimeException: Font asset not found b4x_fontawesome.otf
at android.graphics.Typeface.createFromAsset(Typeface.java:301)
at anywheresoftware.b4a.objects.TextViewWrapper.getTypeface(TextViewWrapper.java:155)
at anywheresoftware.b4a.objects.TextViewWrapper.build(TextViewWrapper.java:183)
at anywheresoftware.b4a.objects.ButtonWrapper.build(ButtonWrapper.java:98)
... 19 more
main_activity_create (java line: 353)
java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (Button).
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at b4a.example.main._activity_create(main.java:353)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6823)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)
Caused by: java.lang.RuntimeException: Object should first be initialized (Button).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4a.objects.ViewWrapper.innerInitialize(ViewWrapper.java:73)
at anywheresoftware.b4a.objects.ButtonWrapper.innerInitialize(ButtonWrapper.java:39)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:435)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:454)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:148)
... 14 more
--------- beginning of crash
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:21)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:349)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:454)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:148)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at b4a.example.main._activity_create(main.java:353)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6823)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)
Caused by: java.lang.RuntimeException: Font asset not found b4x_fontawesome.otf
at android.graphics.Typeface.createFromAsset(Typeface.java:301)
at anywheresoftware.b4a.objects.TextViewWrapper.getTypeface(TextViewWrapper.java:155)
at anywheresoftware.b4a.objects.TextViewWrapper.build(TextViewWrapper.java:183)
at anywheresoftware.b4a.objects.ButtonWrapper.build(ButtonWrapper.java:98)
... 19 more
main_activity_create (java line: 353)
java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (Button).
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at b4a.example.main._activity_create(main.java:353)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6823)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)
Caused by: java.lang.RuntimeException: Object should first be initialized (Button).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4a.objects.ViewWrapper.innerInitialize(ViewWrapper.java:73)
at anywheresoftware.b4a.objects.ButtonWrapper.innerInitialize(ButtonWrapper.java:39)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:435)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:454)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:148)
... 14 more
Copying updated assets files (2)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **


thx
 

Star-Dust

Expert
Licensed User
Longtime User
So the error is not in BT_Printer.Initialize.But rather it would appear in something that is in the Layout.

Try like this:
B4X:
Try
    Activity.LoadLayout("MAIN")
    ListView1.SingleLineLayout.Label.TextSize=14
    ListView1.SingleLineLayout.ItemHeight=30dip
  
    Printer.Initialize(Me,"Printer",Encoding.Windows1252)
    Preview.Color=Colors.LightGray
Catch
        Log("error: " & LastException.Message)
End Try
 

kurniahenki

Member
Licensed User

Dear Sir

Now the layout can show when running on release, but the problem is wherever i click any button or radiobutton it showing error application stopped and suddenly close the apps.

thx
 

Star-Dust

Expert
Licensed User
Longtime User
It is clear that you have misunderstood the problem.
You wrote that the release was interrupted, and you indicated Printer.Initialize.

Now you're saying that compiles and starts, but stops when you click a view in the Layout.

Actually the error that appears in the registers is not of my library but of the Layout.

Are you using an old version of B4A?

The strange thing that debugs you work ... so there is something that escapes.

The only problem, a could be access to File.DirInernal that my library uses in the DEMO version.

But tomorrow I can produce an example that can identify this problem. For today I can not give you any more help
 
Last edited:

kurniahenki

Member
Licensed User
Many Thanks Sir

my version B4A is 8.50 and registered version.

with my other coding is never happen problem with Activity.LoadLayout (when not using SD_BT_Printer), but i really like you library, it can help me much.

when i try to set like this :

Sub Activity_Create(FirstTime As Boolean)
Try
Activity.LoadLayout("MAIN")
Catch
Log("error on layout : " & LastException.Message)
End Try

Try
ListView1.SingleLineLayout.Label.TextSize=14
ListView1.SingleLineLayout.ItemHeight=30dip
Catch
Log("error on listiew : " & LastException.Message)
End Try

Try
Printer.Initialize(Me,"Printer",Encoding.Windows1252)
Preview.Color=Colors.LightGray
Catch
Log("error on printer : " & LastException.Message)
End Try
End Sub

everything work fine even with release, no error and all function can work fine.

I'm just curios why should be have to using try on Activity.LoadLayout.

I'm looking forward for your another example so can identify the problem.

One thing : each time i'm trying print barcode using your example for the first time success with barcode not completely print, and trying print barcode again it prints not barcode but weird code , and trying to print again back to first result barcode image not completely print.

for the text print is success with no error.

You Are The Best.

Many Thanks
 

kurniahenki

Member
Licensed User
Dear Sir

I'm really sorry , it's all my mistake, just found the cause of problem with activity.loadlayout,
it happens that buttonprint is using image and the file of image doesn't exists.

after i change btnprint without using image everything going normal.

the problem now is :
each time i'm trying print barcode using your example for the first time success with barcode not completely print, and trying print barcode again it prints not barcode but weird code , and trying to print again back to first result barcode image not completely print.

for the text print is success (perfect) with no error.

thx
 

Star-Dust

Expert
Licensed User
Longtime User
I asked you if I changed anything and you said no.

It could be too big and not be contained. Or if the transmission is interrupted too much.

Before printing an image, try to reset with ESC_POS.InitializePrinter
 

vecino

Well-Known Member
Licensed User
Longtime User
Hi, how can I try the demo?
I press the button on the printer and it shows a toastmessage saying that it is demo.
Thank you.
 

Star-Dust

Expert
Licensed User
Longtime User
Hi, how can I try the demo?
I press the button on the printer and it shows a toastmessage saying that it is demo.
Thank you.
The demo can only be tested for 7 days. You used it for too long.

Hi, I am testing your library and I see that there is no example Send_Buffer_to_Print_flush.
It's a mistake?
Regards.
In your message of June 19, 2018 tell me that you have tried the library.

So what other tests do you want to do now ?
 

vecino

Well-Known Member
Licensed User
Longtime User
I did not get it to work in those days. I left it parked. Today I tried to try it again.
Thank you.
 

vecino

Well-Known Member
Licensed User
Longtime User
Hello, really? Is that the control?
I tried to try it, it did not work and that's why I asked.
Now I said to myself: "I'm going to try again."
I downloaded the demo version and I have not let it prove it.
Anyway, thanks.
 

Star-Dust

Expert
Licensed User
Longtime User
I'm happy to present the update to version 0.15. I have also updated the examples to post#1

  1. Now the list of printers and MacAddr in a Map.
  2. The new version (FlushAndClose) will give you 14 days of trial from the installation.
  3. It is possible to store an image in the printer and recall it without having to transfer it every time.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
The new version will give you 14 days of trial from the installation.
How do i Print something with the connected Printer?

If i click on the Print Button i get a Toast saying "Demo Library - Sorry not available".

I downloaded the Library and the Demos a few minutes ago for the first time.

I am trying to maybe get my chinese Xprinter Printer to work with this lib.

Hard to test if i can not print in the Demo.
 

Star-Dust

Expert
Licensed User
Longtime User
Sorry, there is an mistake in the example.
The DEMO version can only use the FlushAndClose command and not the SendBufferToPrinter command.

I updated the example at post # 1
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…