2017년 6월 11일 일요일

FAQ for Arduino and Bluetooth


Send a picture and ESC sequences to a bluetooth printer


I want to print on a bluetooth termal printer a little logo with BluetoothClient object.
Is it possible? How can I do it? With which method?

Then, How can I send ESC sequences to set printer as I need? 
I have the necessary sequences, but I don't know how to send them to the printer. 

For example: the hex sequence 1B 21 20 
I have tried with SendText method using "\x1B\x21\x20" in the text, but nothing.

--
Look in the Gallery for application CRLF.
It has a hexify() procedure that uses a trick of the Web component to create single byte text 
blocks from hex.  JOIN them together and sent them as text.

Sending a picture is harder.
You need access to the coding technique used by your printer.

See the BlueTooth section of my FAQ at the beginning of this board for sample apps.

-- 
excuse me but in Blocks section I don't find the procedure "Web.HtmlDecodeText" with parameter "for component".
Between the blocks available for Web component, I see only the block with "htmlText" parameter (see below)

I'm looking for this:

Where I have to search for it? Do I need any upgrade?

-- 
It's in the Any Component section of the Blocks Editor.

-- 

Invalid JWT


I put a quotify method like it says on the  Frequently Made Errors with Fusiontables and how to fix them, but it still  gives me an Invalid JWT signature. Can you please tell me what I did wrong?
--
do the Pizza Party tutorial to learn how to work with fusiontables and how to setup the service account method

--

How does the new property Webviewer.WebViewString work?


in the new release there was introduced the new property Webviewer.WebViewString 
how can this be used?
sorry, the documentation does not help me very much ...

from the release notes:
WebViewer: You can now communicate with the Javascript environment in the WebViewer by providing a string it can read

from the documentation


WebViewString
Gets the WebView's String, which is viewable through Javascript in the WebView as the window.AppInventor object

--
I'm also interested in knowing a bit better how this new feature works,
maybe it will be easy to pass values via javascript and web pages with web component, but how?
an example is really appreciated! thanks!

--
You can use WebViewString to communicate values back and forth between your App, and the WebViewer.

In your App, you get and set the WebViewer.WebViewString properties.

In you webviewer, you open to a page that has Javascript that references the window.AppInventor object, using its getWebViewString() and setWebViewString(text) methods.

For example, if the WebView opens to a page that contains the Javascript

<script>
document.write("The value from the app is<br />" + window.AppInventor.getWebViewString());
</script>

and if you set the WebView.WebVewString property to "hello from my app", then the web page will show

The value from the app is
hello from my app.

Also, if the web page contains javascript the executes the command

windowAppInventor.setWebViewString("hello from Javascript")

then the value of the Webviewer.WebViewString property will be the text "hello from Javascript"

Taifun has done a lot of tricks that use the Web page title as a communication channel.  This is essentially the same thing, but
without needing to use the title.

We'll update the documentation to be more clear.

Does this explanation help?

--
How about some blocks Hal?   Thanks.

--
Great update.

.-- 
Does this explanation help?
thank you Hal, this should help me to prepare an example soon

--
a basic example how to use this can now be found here http://puravidaapps.com/snippets.php#2webviewstring
webviewstring.aia


Thank you Hal! This offers some possibilities!

--
Jeff deserves the credit, not me -- I just reported what he did.

Thanks for writing this up!!

By the way, then I create those Javascript pages, i use android file transfer to put them in a directory like /Temp/stuff.html
Then from the app, I use the URL file:///sdcard/Temp/stuff.html

That works both in developer mode and production mode, although it does leave junk in the file system that has to be deleted lateer

--
Good example Taifun.

The example sets a global true/false variable development but instead refers
to a hardwired true in the Screen1.Initialize URL choice step.

The if/then/else should query development.

--
thank you ABG, now fixed

--
a probably more useful example is now available here
App Inventor and Dynamic Table Layout now using the new WebViewString property

--
Say I wanted to send 2 paragraphs from a textbox in my app to an html page with the necessary Javascript, what is the limit of characters I can send without error?

--

JavaScript to pass information from HTML to WebViewString


I'm managing a list of proverbs in the WebView component as follow;
document.write(window.AppInventor.getWebViewString()); as the JavaScript to receive the HTML content or <body>.

The WebViewString is set to:

<ul>
<li>Maisha  mazuri</li>
<li>tenda wema nenda zako</li>
</ul>

Now I wanted to extract the <li>( innerHTML) with an onclick event and share it using the SHARING component.
I tried this <li onclick="javascript:window.AppInventor.setWebViewString(this.innerHTML);"> 
but failed to get the text via window.AppInventor.setWebViewString() as shown in this tutorial.
webviewstring.aia

Please, I need your Help!

--
Three things to try:

Check that "this.InnerHTML" actually contains what you want back?

Remove the word javascript:

onclick="window.AppInventor.setWebViewString(this.innerHTML);"

Might it need to be in a "link" ?

<a href="javascript:;">onclick="window.AppInventor.setWebViewString(this.InnerHTML)"></a>
or
<a href="javascript:;">onclick="window.AppInventor.setWebViewString('this.InnerHTML')"></a>

-- 
Also , just an observation (based upon what you have disclosed):

If you are seeking to collect the same information as you are feeding the html, why not setWebViewString as an index number, collect that, and use the index to call up the data from a list?

Unless I have missed something?

-- 
Thanks a lot Tim.

I tried these methods on Samsung Galaxy Note 2(android 4.1.2), it worked very well.
But failed on other devices (android 4.4.1 and higher)...


--

Simple Demo for Notifier Progress Dialog


Just a simple demo of how to use the Notifier Progress Dialog

I am sure there are many other ways......:)

How To Make Progress Bar In Notifier


How To Make Progress Bar In Notifier Like A picture Given Below


--
that's unfortunately not available
alternatively you could use the Notifier.ShowProgressDialog or see the solution here https://puravidaapps.com/filebyfile.php
FileByFile.aia
FileByFile_Drive.aia



-- 
The link you have given is taking me to wrong location.

--
Works OK for me, you should see some blocks for a progress dialog demo

Anyway here they are:



-- 
Thanks for you help.

--