2016년 12월 14일 수요일

App that notifies you when you are near a specific place


I'm trying to make a gps and google maps based appthat notifies you when you are near specific places. You can set the places from the start (banks,coffee shops,hotels...) and when you are some meters away a pop up message pops and tells you, for example "You are near sunshine hotel"!!
I tested with some coordinates and it notifies me correctly but I would like to make a list of coordinates and pass them to the ai2 so I can have many places set up and their pop up messages.
Can you help me? I'll post the block Imade to notify you when you are at some coordinates for you to see.


I would like to make a geofence like that but don't know how... If you can help me with that also please.
--
Here are some suggestions.   Also google using search for messages in the forum with   List as the search to learn how to use Lists.

You have a good start.  Sorry, there are already issues with your proposal.

The tutorial Exploring with LocationSensor in AI2 https://docs.google.com/document/d/1V1Zm5cYoa12KVb_cTlfelSfyUkW7IH2WPHUoTa02XaY/pub
explains that a difference of 0.00001 of a degree of latitude  converts  to 0.9144 meters.   You probably read that but are you aware:

40.93563
40.93565
_________
0.0002  at 0.00001 x 20 = 18.29 meters approximately

24.4002
24.4004
_______
0.0002  at 0.00001 x 20 = 18.29 meters approximately  (longitude varies South to North) but the latitude approximation might be good enough.

Your example ring fence is 18 x 18 meters.   Your GPS seldom has an Accuracy (see the above tutorial) that good .  Some times when you get a satellite fix Accuracy will be 12 m, sometimes 2, sometimes 50.  So what happens if you use a ring fence as small as you show in your example?  Can the GPS always resolve an 18 m diameter circle?

To know whether the device is within 150 meters of the location using this technique, shouldn't your difference in Latitude/Longitude   be   0.00001 X 0.9144 (approx 1 meter) x 150 meters ; that is should the sizes of the ring fence be at least 0.015 degrees on a side?  Perhaps you want a larger ring fence box?

If you want the algorithm to be generic;  consider using variables in the ring fence equation. The boundaries for the ring fence can be created using your List of places ('Sunshine hotel'  , 40.9xxxx , 24.4xxx) or however you create your List or List of Lists to handle geocoordinates and venue ).  Create  VenueLatitude and VenuLongitude variables and populate them with lat and from your List of places. Do the same for the venue longitudes (east/west).

Call the Northern latitude perhaps NLatitude also create SLatitude and Elongitude and Wlongitude perhaps    get NLatitude > (Vemieatitude + 0.0075)   and  get Slatitude < (Venuelatitude - 0.0075)   and the same for the longitudes?   0.0075 degree is one half of a ring fence side.  If you use a generic solution you can use the same information to populate a polygon as mentioned below.

I know of now way to populate a static map with a circle as shown in your image.  You can use pipes and draw the sizes of your ring fence using the Google API as a box or use a polygonal area .  Perhaps use a square based on your ring fence dimensions instead of a circle.  https://developers.google.com/maps/documentation/static-maps/intro. Keep in mind Google restricts the characters in a url used to capture a static map to 2,048 characters.

Creating an app like this is getting very complicated. You can create something similar to what can be done with the Java compilers if you take one step at a time. The key word is similar ..AI2 does not have all the tools necessary to use all the Google API features.  Experiment with small pieces as you have already started to do; keep it up.  Make a small test example using two or three venues.  If you still have issues, show your progress and ask again.

Another solution might be to use a Fusion Table with all your venues loaded and use the FT mapping capabilities..   If you do it this way, you are however restricted in how you can annotate the Fusion Table map.   See the post here to get an idea as to what that is all about  https://groups.google.com/forum/#!category-topic/mitappinventortest/oKFMCEt1kRs

-- 
thank you very much you helped me a lot!! :D
I made some lists and they kinda work but I need somemore help with them.
The notification pops up all the time like every two seconds. I need you to help me. I want to make a loop that for everytime it finds a right location (everytime if statement is right), it stops the loop.




-- 
It appears you have the beginnings of a good test Project.  You now have a generic ringed fence algorithm that works.
There are still issues you certainly can fix get your app to work they way you want.  Ask yourself why does the notification appear every two seconds in your test app?  

Your notifier block located is in your LocationChanged block.  That meansvthe ringed fence if statement tests every time your LocationChanged event is triggered/
If the ringed fence if statement is true, your vibrate starts and you get a notification message probably.  ...and it happens about every two seconds?  That frequency tells you something.  To get a repeat message, the LocationChanged event must fire (execute) again.  Think about what can cause the event to fire every two seconds?   What is your LocationSensor  TimeInterval set to?

This image shows one place TimeInterval can be set circled in red.  The example shows 60000 which polls the LS once a minute (6,0000 ms).  Polling every two seconds does not seem reasonable to me.

The other place a developer can set the TimeInterval is using the blocks above.  You did not show one of these blocks in your code so it appears you set the interval in the Control.  I expect you are polling the LS to get a satellite fix every 2000 ms (every two seconds?)  or your DistanceInterval is NOT 0.   Is that true?

However, there is another reason the LocationSensor might fire.  Did you set the  DistanceInterval to a NOT 0 value.   Is that true? If it is, read the MIT LocationSensor tutorial to find out why setting this to a different value (in meters) can cause the LS to fire?  Both options can be set but doing so can lead to confusion.   I would keep DistanceInterval at 0.  

Did you set the LocationSensor DistanceInterval to something other than zero (  0 ms )?  An interval of not 0 could cause frequent tripping of the LocationSensor.

Your code to determine if the device's current location is within the ringed fence is now within the ChangedEvent block.  This does work but is not the best programming practice. AI2 blocks execute asynchronously.  Better to place your ringed fence blocks into a procedure outside the ChangedEvent block and call the Procedure within the ChangedEvent block instead. The less code a developer places in LocationChanged the better.  Using a procedure allows you to avoid 'timing' collisions in code execution. However, a potentially better solution is described below (the ringed event Procedure in a Clock).

You said " I want to make a loop that for everytime it finds a right location (everytime if statement is right), it stops the loop."   OK.  A loop might not be your best solution.  A loop could work depending on your code.  Using a Clock might be a better solution (perhaps place your ringed fence Procedure into the clock, after you call the ringed fence procedure, use a block to turn off the Clock (Clock.TimerEnabled is set to false) ).   If you do that you have many options to turn off the notifier after if 'finds' a venue.  There are other ways of disabling the notifier...this suggestion is simple.

Use Boolean switches (check for a state of true or false).   Create a variable called   VenueFound and initially set to false.   If VenueFound is false then  call Notifier1 else if VenueFound is true then do nothing. 

Try some code.

Ask yourself why you send an address to your TinyDB everytime the LocationSensor fires.  Why do you do that?   You are collecting a lot of CurrentAddress events, but why?

-- 
Well as I was searching and trying tutorials I did that and forgot it (see the block).
The interface of my app is that.


The buttons are : 1)Museums, 2)Hotels, 3)Petrol Stations, 4)Cashpoints, 5)Coffee, 6)Fast Food, 7)Pubs and Bars, 8)Restaurants.
If you press one button then the black X goes away and that means that when I walk near a location that this button describes then it notifies me. For example if the buttons Museums and Coffee does not have the black X that means that the app notifies meonly if I walk near (150 m) a Museum or a Hotel.
I have made lists for every button (not finished yet) with latitude, lontitude and place name. If the button is enabled (that means it does not have the black X), then the programm gets in the loop and searches for e.x. Museums and Coffee Shops only and notifies me when I walk near them. Here is my lists for Hotel button.

I'll show you my new loop now. It goes on and on and on....that is something I don't like and I'll try to make a procedure like you told me/



The reason I put the address in a database is because I will need it later cause I want to save them but that's another thing I don't need help right now.
:D Thank you again my friend

-- 

Blocks wont load


On one of my projects, when I try to load my blocks this comes up, The blocks area did not load properly. Changes to the blocks for screen 5891902537465856_Screen1 will not be saved. I didnt save any files on my computer and Ive tries other browsers and its no use, any help?

-- 
I have also tried multiple computers.

-- 
is this a large project? loads of screens and/or loads of components used in a screen and/or loads of blocks?
probably your project is corrupted... just import your lastest backup and restart from there

-- 
Getting the same problems today, weird.

-- 
Did you try with a different browser? (Don't use Edge or Internet Explorer. Those are not supported.
Did you clear your browsers cache and history? Or maybe reset to default settings?
How big is your project? How many components and blocks you have in it? (a few, some, a lot)
Did you try lo load your project on a different computer? What happened?
How is your internet speed lately? Tried resetting your modem/router?

-- 
I used google chrome
Yes i have cleared history and reset default settings
Idk how big my project is, but has 26 components and it had a lot of blocks on one screen
Yes I did try on a different computer, didn't work
Computer is on a school network
And I have no idea how the speeds are, or if the router has been reset.

-- 
Well, evidently is something on your side, since I can get into my projects without problems. 
Sometimes the school network admins change settings and that messes up the access to App Inventor. Do you think something like that happened recently?
You should try on a computer at home or anywhere outside the school network and see what happens.

-- 


Sound recorder crashes AI Companion


Trying to set up to record user input. Set button.click to call soundrecorder.start. On click, AI Companion crashes. Suggestions?

-- 
How to use the Sound Recorder

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

-- 
 blocks.png
As I said, on click of button 1, ->> AI Companion crash.

-- 
did you try the example project?
which device/Android version are you using?
to find out more about the Runtime Error, you can use Logcat

I normally use Eclipse and Logcat there, but if you have installed the AppInventor Software (see also http://appinventor.mit.edu/explore/ai2/setup-emulator.html), you already have everything you need to use logcat...

How to use Logcat

1. connect your device using USB with your computer
2. in File Manager go to the App Inventor directory, which is  C:\Program Files\App Inventor or similar
3. press Shift and right mouse click the subdirectory commands-for-Appinventor to get the context menu
4. select "open command window here" and you will get a command window of that subdirectory
5. enter adb logcat and the logcat will start running
6. start your app to elicit the error
7. copy the log (see below)

To copy your log, right click, click "select all" and enter to copy the complete log into the clipboard, then open Notepad and paste it using ctrl-v.

-- 
I tried the example. Same result.

Unable to get my phone connected via USB. Will continue to work on that.

Other sites have suggested that the mic may be in use by something else. Is there any way in AI2 to force control of mic? I've disabled all apps that look like they might use the mic.

Phone is Blu Energy X Plus. Android version 5.0.

-- 
Update:

I downloaded your .aia file and ran it in AI2. Crashed the Companion. Made an app from it. Loaded on my phone - crashed. Loaded the same app on a different phone - no problems. Works perfectly. 

So, it's something about this phone. I can't find any settings on the phone that prohibits use of the microphone. 

I downloaded another recording app on this phone and it works fine. https://play.google.com/store/apps/details?id=com.sonymobile.androidapp.audiorecorder

So some combination of AI2 and this phone is not compatible.

Suggestions?

-- 
This a problem we've seen before with Android 5.0. The crash appears to happen in some native code called from App Inventor for the purpose of recording the sound. Unfortunately, we don't have a fix for it yet and it only appears to affect this version. Users on older 4.4 devices and newer 6.0 devices don't seem to have these crashes. It's not necessarily device-specific either, as we've been able to trigger the behavior inside of the emulator running an Android 5.0 build. If you have the option of upgrading the device to a newer version of Android, that is likely the fastest way to not be blocked by this.

-- 
Thanks, Evan. Good news and bad news, eh.

I can't upgrade my Android version. Other apps are able to use the recorder on this version. What's the work-around? My app will really benefit from a recorder. Plus I don't want to put out something that won't work on certain versions of Android. Is it AI2 specific? If so, can I just go to another platform? Thoughts?

-- 
I was made aware of this bug on Android 5.0 about a month ago but due to higher priority issues haven't had time to address it. I have no doubt that there is a workable solution, its just that our Media Utilities implementation relies on an Android API that was broken in that release. The crash itself is in native code from the AOSP, not our own code (it's even running in a different process). We are planning to do a release over the winter break, so I'll see what I can do about getting a fix together before then.

-- 
Great! Thanks for your response and attention to this issue.

-- 
I don't understand why you marked that as complete. It obviously is not. The issue remains. Perhaps Evan has elevated it but it's not complete.


-- 
this thread is completed, so I flagged it as complete, 
the issue is not completed, but MIT is aware of it...
I hope, this is ok for you like this


-- 

scroll angements and services app invventor



i noticed that there is no scroll arrangements. why?
could i have them?

-- 
Where are you looking at?


-- 
i'm using the app inventor with tasks...

am i using some outdated app inventor?

-- 
I remember that you were told already that the tasks server is just a test, not ready for using yet.
You can use it at your own risk, but it may even disappear one day or change completely, so I wouldn't risk making apps with it if I were you.
In fact, I don't think the apps you create there now will be compatible with the final version when it's launched.

-- 


Possible New feature for Alphabet Letters or Images


We've seen that a lot of you develop training apps that include tables where it includes Alphabet Letters or Images in table-format, allowing user to click it and it will then sound the alphabet letter or expand the image.

See attached. This may-be a new UI component that can take ElementsFromString (e.g. a,b,c,d,e,f,g,h,.....) and will then display it in table-format and will allow for item selection.

foo.png 표시 중
--
Great idea. 
Yes .. i use it everywhere .. 2017 is going to be awesome ..


--
This Will be a nice feature,  Will it also include images in table?

--
Any tentative date for this feature?  

--
We are working on this and want to include ability to include either text or images. Its work inn progress and we are hard at work but can't give a date. Hopefully it will be soon.

--
Not in hurry, but wanted to know. 


We are working on this and want to include ability to include either text or images. Its work inn progress and we are hard at work but can't give a date. Hopefully it will be soon.


Any tentative date for this feature?  


This Will be a nice feature,  Will it also include images in table?

-- 

check and boolean field on mysql database


I want to use a check in the app and if the check is active i want to store in the database in a field boolean 1 if not 0.

I can store datas like text and numbers in mysql database using pure vida tutorial.

Is there any tutorial for this?

-- 
Store a number or text instead.Why bother if you know how to make a workable solution?
Anyway, BOOL is the datatype in MySQL for booleans.

-- 
how to store a text for example yes of checkbox is checked and store not if checkbox is not active?

--
if Checkbox.Checked 
then set global myText to "yes"
else set global myText to "no"

-- 

App that uses google maps PROBLEM


I already made a part of the app that lets you press the button of the point that you are interested in and opens google maps and shows you near, for example bars, if you have pressed the oubs and bars button. I'm trying to make it alert you everytime you walk near a Point that you have selected (I'll make a button for options and there you wouldbe able to select which points you are interested in to get alerts). The Points could be museums, bars, restaurants, banks, etc. 

Help me please. I already know how to get my current location and I need to make something that alerts me when I'm 100-200 meters from a point.

-- 
It depends.  Are the geocoordinates of your 'bars' loaded in your app or are you using the Google Business Maps API?

If you provide your own geocoordinates:
1. you could use a Clock to run a Procedure that calculates the straight-line distance between the current location and the geocoordinates of the bar. When the distance is < 150 meters, sound an alarm or vibrate the phone. Calculate a distance using simple trig or  using the  Haversine formula.
2) Make a ring-fence.   The following shows how to use a ring-fence properly http://www.appinventor.org/bookChapters/chapter18.pdf  in the section called Programming Complex Conditions
3) Using the LS DistanceInterval property to determine how close your device is to a certain point  (google the forum for a discussion that mentioned   Halte Alarm ..Christophe solved his problem that way.)  DistanceInterval is discussed in the LS tutorial
4) Use the Google Maps API to bring up Google Navigate where if you have the CurrentAddress, you can ask it to navigate with AI2 code and an activitystarter I believe.

If you use the Google Business Maps API I have no suggestions.

Anything here work for you Maria?

Merry Christmas

-- 
Well I tried to do what you said (I also saw Christophs bus app solutions) but i can't find a way to get all the lat long of the nearby locations (museums, restaurants, hotels, etc..). 
I want to choose if I am interested in cashpoint, museums,petrol stations, etc and then walk with my gps and wifi on and the app notifies me when I'm near (100-200 meters) to a cashpoint, for example.
Please help I'll put my code here...



--
Your code that plots your 'cash points' does not provide either the latitude or longitude of those points. The geocoordinates information needs to be in a List or List of Lists so the app can calculate proximity for each venue and use your distance procedure to calculate the distance between the Android and a selected venue from the List.

Your existing code cannot capture the latitude and longitude from each venue shown on the map and post all to a List.  Taifun posted a method where a developer could touch the screen and capture coordinates.  That might work in your case for capturing a single location; you would have to find his method and try it out. http://puravidaapps.com/coordinates.php  to see whether it is practical in your situation.  It would probably be extremely awkward but might work.

At present you can use your static map technique  substituting your device's current latitude and longitude for  the current LablLatadata and LablLondata text blocks and display an image.  That would visually show how close the android is to the venue (you would have to include the google   zoom factor to make that work (zoom to a high value) and would certainly be easier than calculating distance to a location for which you have no geocoordinates.

You could create your own database of the latitudes and longitudes of  ALL the venues your app needs; let the user select a venue and then you can use the latitude and longitude to calculate proximity or if you have a list of street addresses,
let Google Navigate show you how to get to the specific location. That requires maintaining what may be a huge List (duplicating what Google does with Google maps) with AI2.  

To do exactly what you want I expect you would have to use the Google Business API ( https://developers.google.com/my-business/ )  and even then it might not be impossible with AI2. You might review https://developers.google.com/my-business/content/prereqs  be aware, Google provides examples but not AI2 examples.

What you want to do with the Google supplied 'cash points' using the locations shown on the static map display if not impossible.  Perhaps someone has a simple solution. Supply your own cash points and it is relatively easy with AI2.

-- 
I checked all of your links and tried to make it work but its a big mess... 
I saw Taifuns post but I can't understand how to use the api..where should I put the html file? i put it in my phone at the directory he says but nothing works.
Also I tried to use google bussiness api but don't know how to use it with AI2 and all the tutorials are for javascripts.
Anyway I tried to make some list with coordinates already in them and another list with the names of the places but tottaly failed again. Here's a screenshot...


-- 

Text source


I am very pleased with App Inventor, but being an OLD programmer (I assume most of you were not even born when I began to program) I prefer to code using text files, instead of the graphical way.
I looked around but never found somebody who talks about this possibility. I assume the graphics is transformed to text before compilation.
Graphics is great for beginners, but I would like to use the text mode enjoying the ease of Android programming.

Is it possible? 

-- 
App Inventor is to ease the programming for non-programmers.
You may want to consider using Android Studio which provides a full textual programming environment.

-- 
I just hate Java (since it went to Oracle) and its syntax (even before Oracle).
I would dream a simplified syntax, such the one used by App Inventor, without all the trouble. 
Getting older, you know, my time is shorter than average to learn something new :-)

But probably you are right, Android Studio is my way. 

-- 
How about RFOBasic of https://www.touchdevelop.com/ ?
(They don't have nice screen design like AI2, though)

Also, have you tried the little-known typeblocking feature of AI2 ?

-- 
Abraham, I never heard of this RFOBasic. Really interesting indeeed. I will give a look.
I bought Basic4Android but never developed big stuff with it. It is a simplified environment that takes off all the JAVA gibberish.


About the typeblocking, it is almost  what I need: fast writing without drag/drop. I will try with that. I don't know how I could miss it... 

-- 
I had been born for sure  :-(

Try something different, as Ionic 2, for example. The purpose of App Inventor is to teach to young people the bases of programming, using graphics.  

Did you start with block diagram, didn't you?

-- 

Video Tutorial: Basic SpaceShip game


Hello, I have a new video tutorial for app inventor:
this is the info:

Make a basic spaceship game in MIT App Inventor. The spaceship rotates using a canvas drag event. Then we shoot with Touch Up event.

🚀 Hello friends, in this MIT App Inventor tutorial I will show you how to make a simple spaceship game, well at least how to start it, then you will be able to add more ideas to make a full functional game. 
In the video you will... learn? see? how to:

🚀 Use a procedure to Scale and Center a Sprite in the middle of the canvas, no matter the device sscreen size.

🚀 Rotate a Sprite in APP Inventor using heading property and the canvas onDragging Event (use one finger rotates the ship and fires)

🚀 Use the "Z" property in App Inventor to place sprites one under other

🚀 How to shoot the "space bullet" in the direction where the spaceship is facing

🚀  Use a clock to make sure "default properties" load correctly when the screen initializes.

🚀 Lots of mini tips to work work work work work 🎤🎼🎵 with MIT app inventor

Hope you like it!!!



-- 
looks like fun.
Will you post the aia file?

-- 


Simple equations in AI2



I have started only yesterday to use App Inventor and I have a lot to learn about it. For example, I have to quite simple questions for you all..

The first one is: how can i make simple equations on my app? let me explain better. I created a simple app with three text field and a checkbox. in the first two text field I have to insert two number, with the checkbox checked or not I introduce a third number (into two different non-visible textfield). the equation is textbox3 = (textbox1^2/(textbox2*(textbox4[in checkbox checked] or textbox5[in not checked]))). really simple. But i'm not able to make it!

the second question is: how it is possible create an appwith more than one page and connect all pages with button?

-- 
I imagine you're trying to do something like the equation in the attached image. 

-If you don't need to change the contents in textbox3 then I'd recommend using Label1 instead.
-There's probably no need for the hidden text boxes, as you can achieve the desired result with  variables instead (number1 and number2 in the screenshot)
-if you users are only supposed to enter numbers I'd recommend using "Numbers Only" in the design

Finally, for best practices switching screens have a look at this great tutorial:

Hope that helps,

Screen Shot 2016-12-13 at 12.18.04.png 표시 중
Screen Shot 2016-12-13 at 12.24.56.png 표시 중
-- 

I have started only yesterday to use App Inventor and I have a lot to learn about it
See the free books section of this FAQ:

--