Android Question Trying to print from webpage for bluetooth

mrjaw

Active Member
Licensed User
Longtime User
Hi!
I am have an web app that is responsive. It works so fine on cel and tablet but now I have a problem, I need to print something from that page. I use chinese printers , printing by bluetooth , I am trying to print it.
I think to do an app that read something from page and print it.

Somebody here has any cluue to do a "printserver" or comunicate both app , app and webpage.

The idea would be :

webpage <--> app <--> printer

or if I can print from webpage using bluetooth like rawprint , I wanna hear.....

Thks
 

mrjaw

Active Member
Licensed User
Longtime User
Precisely, Erel, anybody has any cluee how to pass this information to native app ??

Any cluee"?
 
Upvote 0

mrjaw

Active Member
Licensed User
Longtime User
I am thinking to use cookies to save the info to cimunicate with native app. Where android save the cookies>?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
B4A does not save any Cookies. Android even does not do it. The Browser is responsible for saving (and reloading) cookies

If you know how to print with b4a then you can call the webside inside a webview with webviewextras and javascriptinterface.
You then send build your own solution to call a sub giving some data in your app from your webpage (you need to have access to the webside though)

Or is the webside not YOUR webside?
 
Upvote 0

mrjaw

Active Member
Licensed User
Longtime User
It is my website, the idea was save into a cookie the info to print so an app service check for this cookie and take the info to print
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
It is my website, the idea was save into a cookie the info to print so an app service check for this cookie and take the info to print
You dont need cookies or whatever... Insert javascript in your webside to send data like in the Webviewextras-example (escpecially WebViewExtrasDemo).
See this code and have a look at the html-code to understand what´s happening
B4X:
Sub GetString As String
    Return "This is a string from the B4A demo code"
End Sub
Sub ShowToast(Message As String)
    ToastMessageShow(Message, True)
End Sub

Click <a href="javascript:void(0)" onclick="B4A.CallSub('ShowToast', true, 'Hello from javascript')">HERE</a> to call a Sub in the B4A demo code.
Click <a href="javascript:void(0)" onclick="alert(B4A.CallSub('GetString', false))">HERE</a> to call a Sub in the B4A demo code which will return a string to this page.<br />
A B4A Sub can only return a (string) value to the javascript if the CallSub() method is passed boolean false as <b>callUIThread</b>.

So. If you know html and javascript then you can easily build a communication from your webpage with javascript to your app.

If you know how to print data from within b4a too then you should be able to pass all the needed data to print with CallSub
 

Attachments

  • wvex.zip
    9.6 KB · Views: 222
Last edited:
Upvote 0
Top