2019年12月20日金曜日

App Inventor version nb181 (December 19th, 2019)

MIT App Inventor is constantly upgrading, including minor improvements and bug fixes. I'd like to talk about two things that I've paid attention to in this release of "nb181". They are improved XML decoding and the addition of pressure sensor component.

XMLDecode Now Handles CDATA Sections
In XML, you may want to use markup symbols in regular strings. For example as in the following figure. However, XMLTextDecode in the XML Web component did not handle the "![CDATA [...]]" sections well. Therefore, these sections had to be removed as follows:


This issue was discussed by the community around 2015. As a countermeasure, Taifun [1] presented the above method. However, this version of App Inventor seems to have solved this problem.

Addition of Barometer
I developed several apps that use the barometric sensor built into the Android Phone and published them at the MIT App Inventor Summit 2014 [2]. At that time, App Inventor could not use the barometric pressure sensor, so I created a small Java program to get the barometric pressure value and called it with ActivityStarter.

An example of an Android application using a barometer [2]

Since then, I have used barometric pressure components [3] installed in AppyBuilder and Taifun's Extension [4]. However, with this version upgrade of App Inventor, you can use barometric pressure sensor as one of the standard sensors without using them. Great!

References

[1] Taifun's post on CDATA
https://groups.google.com/forum/#!topic/mitappinventortest/TZO5InFSIkU
[2] Fujio Yamamoto, “Rapid Prototyping Using App Inventor in Information and Computer Sciences Course”, Proc. of the MIT App Inventor Summit 2014, 3 pages, Cambridge USA, July 2014.
[3] PressureSensor by Hossein's Appy Builder
http://appybuilder.com (AppyBuilder is being integrated with Kodular)
[4] Taifun's Barometer Sensor Extension
https://puravidaapps.com/barometer.php

2019年12月11日水曜日

Finally arrived! Beautiful mountain photos that were automatically recognized!

In the previous article [1], I mentioned the recognition of photos from live cameras that shoot mountains. And I have developed an app that can automatically receive it by e-mail only when a photo with a clear view of the top is obtained. In order to recognize photos, I created a model in which many photos of the mountain were classified into four categories and trained. There, I used MIT's Personal Image Classifier and Google's Teachable Machine2 and incorporated the trained model into the App Inventor app.

However, in general, mountains are often covered with clouds. For example, at Rishiri Mountain in northern Hokkaido, you can see the middle but rarely see the top. So, I checked the weather forecast, and on a sunny day, I ran this app continuously from the early morning and waited for a notification email. During that time, of course, I was doing another job because it is fully automatic notification!


Finally, good luck came. It happened after 12:00 that day. As shown in Figure 1, the mountain photo was judged to be “clear enough to see the summit” and I received an automatic email to inform it. I was very happy. Sure, I got a great photo that looks good up to the top of the mountain.

References
[1] Using MIT's Personal Image Classifier with App Inventor
http://sparse-dense.blogspot.com/2019/12/using-mits-personal-image-classifier.html

2019年12月6日金曜日

Another example using JSON Decoding Extension

This article shows an example of using the JSON Decoding Extension I developed. Below are descriptions of this extension:

https://sparse-dense.blogspot.com/2019/01/a-json-decoding-extension-for-app.html
https://sparse-dense.blogspot.com/2019/01/a-json-decoding-extension-for-app_19.html

First of all, I would like to thank many people for their interest in this extension. In fact, these two articles have been accessed more than 1,500 times in total, but sometimes there are inquiries that they can't use it well. So here's another example that's simple but practical. It is a display of the weather forecast using OpenWeather ([1][2]). Here, the weather forecast of Sapporo City in Japan, up to five days in advance every three hours is displayed. An example of a JSON text as output from OpenWeather is shown in FIg.1. Some parts are folded in the figure, but if all are expanded, there are 1,341 lines.


In this JSON text, all the tag values shown in red frame are taken out and displayed on the smartphone as shown in FIg.2. In other words, the city name, date and time, temperature, and weather are displayed. In order to use OpenWeather in an application, it is necessary to obtain an API Key.


Here are the points of using the extension (FoYoJSON) to decode this JSON text. For example, to get the city name "Sapporo-shi", treat it like Fig.3. In addition, to retrieve all the weather forecast every three hours in order of time, write as Fig.4.



The complete source code (blocks) of this application is shown in Fig.5.



If you take a little more time, you can create a more practical application as shown in Fig. 6, where there are four cities registered and can be switched with the button.



Thanks
I found out that this Extension was introduced by CERCA [3]. Thank you for your correct understanding of my design intent and usage.

References

[1] to get OpenWeaterMap API guide:
https://openweathermap.org/guide
[2] to get City ID:
http://bulk.openweathermap.org/sample/city.list.json.gz
[3] CERCA NEL, Estrarre dati da JSON con una comoda estensione di appinventor, novembre 15, 2019
https://osmtreeathlon.blogspot.com/2019/11/estrarre-dati-da-json-con-una-comoda.html