2014년 11월 29일 토요일

how to create a back button to show previous arrangement?

I have created an app with 40 different arrangement divided over 2 screens. Only one arrangement are visible at any time. The app will navigate you through these arrangement from what buttons you press. I have created an arrangement with a "back" button that's always visible, but I'm not sure how to "code" this. 

I want the back button to take you to the previous visible arrangement. Is this possible without 1 mile long code?

I hope you understand me and I appreciate all feedback



these 40 arrangements, do they look totally different or do they look the same or similar?
if they look the same or similar, you could have used only one arrangement and set their content programmatically using lists, which reduces redundancy

store the component of the previously visible arrangement in a global variable. then for the back button write a procedure which sets all arrangements to visible = false and only the arrangement stored in that variable to visible = true

it also helps to use the advanced blocks for the procedure, see an example with buttons here

A Multiple Choice Quiz: How to work with the advanced features




Thank you Taifun. I will try the last example. all my arrangement contains only text, buttons and images (and two arrangements with listpicker)


use blocks=object on another screen & few toughts on database in App inventor


at 1st) 
I'd be very pleased if I can include  procedures variables ( especialy those customized by myself).. from one screen to another so it'd be really object oreinted - and maybe also another existing blocks from scren 2,3..x like there's option for 'any other component' - you click on it and options list reveals

2nd) 
why not enable real database enviroment - cause right now I can only wokr with TinyDB - I know storage limitations on MIT servers. But it'd be nice if I can create normal database - e.g with InnoDB engine ( create tables, foreign keys...so I can create a real production app and don't need to rebuild it or rewrite), but the size'd be limited - certain amount of space = certain amount of rows so the usage of the disk space won't be any bigger. Or is maybe if teh developrers create some API to connect my DB stored somewehre else on the internet

--

ad 1: yes, these are great suggestions!

currently global variables are only global for each screen, to pass values from one screen to another screen use TinyDB or pass a list in the open another screen with start value method http://appinventor.mit.edu/explore/ai2/support/blocks/control.html#openscreenwithvalue

ad 2: yes, it would be nice to have a SQlite component, which is anoffline relational database, this would be easy to implement and there already have been discussions in the past...

In the App Inventor Open Source Group Hossein presented his very nice SQLite enhancement for App Inventor, which offers access to the local SQLite database on Android devices for App Inventor apps.

However, it has been saidthe primary target audience for App Inventor are people with little or no programming experience. And let me add something to make that a little bit clearer: there is no secondary target audience!
Which means, Hossein's SQLite enhancement in its current form will never make it into MIT App Inventor.

I prepared a workaround see here 
How to access the local SQLite database on your device with App Inventor
 also AiLiveComplete offers a SQlite component


Or is maybe if teh developers create some API to connect my DB stored somewehre else on the internet
for online databases you have several possibilities, for example to use a fusiontable, see the Pizza Party tutorial or see here https://puravidaapps.com/tutorials.php#db

--
so it means I've to download AILiveComplete by Hossein and then I can 'run' SQLite in appinventor? and does it run it on Linux?

--
No.  What it means is you got to post on Hossein's AILIveComplete forum and ask there; or pay Taifun for his third party solution.  LINUX? -- ask Taifun or Hossein.

App Inventor is a free  entry level compiler intended for beginning programmers and to be used primarily in a classroom environment, to stimulate one's imagination.  Taifun's post indicated there are no plans by the MIT AI Development team to incorporate SQLLite in App Inventor.

Another solution: start programming in the Java based Eclipse or Android Studio, free professional compilers  or a relatively inexpensive compiler like Basic4Android or one of the expensive compilers available commercially.  These tools can use sqlLite .. (I am not sure about B4A).

And another solution:  Write your own solution for App Inventor, AI is an OpenSource project:  http://appinventor.mit.edu/appinventor-sources/   Plug-in controls are possible.

--
so it means I've to download AILiveComplete by Hossein and then I can 'run' SQLite in appinventor? and does it run it on Linux?

for questions about AiLiveComplete, please ask here: https://groups.google.com/forum/#!forum/apptomarket

--

Sort Distance In a List


i have a web database with 4 field (name, address, latitude, longitude) , now i would populate a list in appinventor retrieving those data from the database and i would order this list by distance from me (closer first). 
I have read how to import data from a webtinyDb , and it is not so hard, but could you address me to the right way/the right "logical workflow" to do what i want?
For example i don't understand where/when is the best step to order.... 

ps. I already have the algorithm to calculate distance from two point on a map

-- 

in case you are using a fusiontable, you can sort easily using the ORDER BY clause, see also SQL Reference Documentation of the Fusion Tables API.

SELECT * FROM <tableid>
ORDER BY ST_DISTANCE(<location_column>, <coordinate>) 

--
Thank you Taifun, i'm trying yo use Fusion Tables, but i have a very big deal with sharing step.
Isn't it possible to share my table with everyone after google login? Is real necessary to specify all the email address??! (or create a group)

--
If all you want to do to share your fusion table is to have other users just VIEW it, then all you need to do is allow sharing for anyone who has the url in the Fusion Table options; then provide the Fusion Table url to those you want to share.  They can view the table using their browser on their PC  or   you can code to use the WebViewer to bring up the page.

--
Could you explain me better? 
<Location_Column> should be in address or in coordinate?
<coordinate> are my actual coordinate?

How can i display in my app all the point stored in a map similar to "map of location" tab in fusion table ?

--
I found a workaround for the "everyone" sharing option... That is store my account in a variable and let the application to connect always with my login...
But i don't know how to do that...

--
@Alfo Pietro.... I do not recommend you use your workaround.  You should not share your login.


--
Could you explain me better?
<Location_Column> should be in address or in coordinate?
<coordinate> are my actual coordinate?
sorry, I never tried this, but you should be able to find some examples doing a Google search...
and yes <coordinate> is your actual coordinate

--
Thanks both...

I have one more question... i took my "Map of Location" link from the Publish button in Fusion Table. It works fine if i use the WebViewer component or if i copy/paste the link in a browser on my computer. But, if i want to use ActivityStarter to open google maps ,passing it my link, it does not show me the marker point on the map.
Maybe i should use different parameter for Activity Starter?

Action: android.intent.action.VIEW
ActivityClass: com.google.android.maps.MapsActivity
ActivityPackage: com.google.android.apps.maps

The parameter above doeasn't works.

--
that link will not work with Google Maps, you can use that link with the webviewer or alternatively you can use the activity starter to open that link with a browser

                       Open the browser to a Web page
Use these activity starter properties to open a specific web page:
Action: android.intent.action.VIEW

--
i Have a map into Vewbviewr with several marker point. What i need now is that when i click on a point, the cards opened with all the information , and a link permit me to navigate to that point..... or somethings like that... in any case i need that clicking on one point, i see the cards, and also a way to navigate to that point... like in "normal" google maps 

--
This explains what you need to do with your fusion  table....https://support.google.com/fusiontables/answer/2527132?hl=en

What you want to do is NOT easy but doable with Ai2.   Perhaps someone will give you a complete example but I doubt that.

Try some blocks; that is what programmers do.   You can set this up without using AI2 since you already have your fusion table; you just have to learn how to use the fusion table...which is not an AI2 toy.   There are examples in the Google API and on the Internet.

So many people believe EVERYTHING has to be done on the Android device.  That is just not smart thinking.   AI2 is very limited in what it can do compared to other Android compilers and what can be done with Windows.  

--
ok, thank you, just another question, i followed the "pizza party" tutorial, and i'm able to populate table and retrieve context. But i don't why if i try to do any custom query like a easy "order by name" , i receive always error. 
Could you show me the right step/blocks to do for a custom query? I can't really understand why i can't....

--

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

--
Sorry but at the moment i'm traveling for work and i can't make screenshot.
Anyway, basically my problem is that in Pizza Party tutorial there is an Insert Statement and than a webViewer component that show all the table.
But , if i have a button with a SendQuery () command, how can i display in WebViewer the returned row only?


--
to display the result in the webviewer, you can alternatively define the SELECT statement in the URL, see also here https://plus.google.com/104335783693415100996/posts/G1NRtEuznTQ


--

can mit app inventor trigger an alarm???

i want to make an android application that can trigger and alarm when i read some data at the certain point..
can anybody here help me??

--
You can use the Sound or Player component to start a short mpg3 sound bite stored as a resource or use the Vibrate block.

What have you tried?    Post some blocks and you will get specific advice from someone.

--
If you're asking about Push Notifications, the answer is no.

--
 Capture.PNG
this is my block..
i want when i the global temperature achieve or more than 30 it trigger the sound??
is my step true??

--

You first have to establish whether the bluetooth device is reporting any temperature data at all .    Is your device reporting a temperature value?   This chapter shows how to use the AI2 debugger called DoIt ..http://www.appinventor.org/bookChapters/chapter15.pdf. You can use it to provide values  or write a simple project to see if bluetooth is recording temperatures.

After that is done, you can read about the proper way to use logic blocks to establish a condition (like temperature above 30) by reading  http://www.appinventor.org/bookChapters/chapter18.pdf  

--
In addition to what Steve said above, remember that your app may go to sleep, or may be shut down unexpectedly by the Android OS... you would only get the alert sound you desire if the app is running and in the foreground.

--
my device has been reporting the temperature..now here the other problem I face..
the sound keep playing whatever the temperature value.. 

--
Keep a global variable that tells you whether or not the alarm has been sounded... if it's true, then don't sound it again.

--
 forum.PNG

this is my latest code block..its keep play the alarm what ever the value of temperature..did i wrong?

--

i want when i the global temperature achieve or more than 30 it trigger the sound??


I would use an if statement like this:

if get global temperature > 30
then Sound.Play

--
The way you've written that block, the sound will play every time the clock (timer) fires.  You need to move the SoundPlay block up where you're doing the test.

Right now, the sound plays constantly.  Also, the evaluate but ignore block doesn't do anything.  It just evaluates the statement but completely ignores the result.

You need an if statement as Taifun showed you above.

--

Can MIT App Inventor get readings from a gyroscope sensor via Bluetooth ?


I am new in Android App programing? I am looking for a simple app or tutorial that I can get readings from gyroscope sensor via Bluetooth; so the gyros sensor will connect to a bluetooth module and send data to an Android device via Bluetooth  communication . Any suggestions? 

--
The Sensors possible with App Inventor 2 are in the Sensor controls. There is no gyroscope sensor tool in AI2.     Can what you want to do be done outside of AI2?  Check back here; someone might have a third party solution.


--
To make it clear , I mean this is external gyros not built in gyros from the android device. So I think I need Bluetooth APIs; so do App Inventor 2 support for the Bluetooth network stack, which allows a device to wirelessly exchange data with other Bluetooth devices?


--
What AI2 can do with Bluetooth is discussed here: http://ai2.appinventor.mit.edu/reference/components/connectivity.html   That may help you, so it is possible you can talk to those gyros if they are Bluetooth and you have that device's API instructions.


Your specific question Khang, I do not know... hopefully someone else will comment.

What forum members have discussed about Bluetooth with Ai2 is here: https://groups.google.com/forum/#!searchin/mitappinventortest/bluetooth  

Creating e-mail body and subject in the app

I am creating an app in which i have taken two textboxes and one button.I want that when the button is pressed the text in first textbox becomes the subject of an e-mail and the text in second textbox becomes the body of the mail with the e-mail destination mentioned in the blocks section.Please i would be glad if i get the block code demo of my problem.Thank you all.



How to send an eMail

Advice: Before posting, it's a good idea to search in this forum. Many others have likely run into problems similar to yours. How to search see screenshot.



What you want to do is accomplished using the ActivityStarter and is explained here:  http://ai2.appinventor.mit.edu/reference/other/activitystarter.html  

Start the mailer with pre-addressed message

To start the Android mailer application, use the action android.intent.action.VIEW . You can use Activity starter's DataUri property to specify the recipient, the subject, and the body of the message. In each case, starting the activity will bring up the Android mailer, and you can complete the message and then press "Send".
For example, if you specify:
Action: android.intent.action.VIEW 
DataUri: mailto:santa@northpole.com
then starting the activity will bring up the mailer, with the addressee filed in.
If you specify:
Action: android.intent.action.VIEW 
DataUri: mailto:santa@northpole.com?subject=Please Santa&body=Bring me a pony.
then starting the activity will bring up the mailer, with the addressee, the subject, and the body filled in. You can use the mailer to edit these before sending the message, if you prefer.
The DataURI here must be a URL encoded message designed to work with the internet mailto service. Search the Web to find appropriate documentation and tools for creating these, for example Elements of a Mailto: URL
Try some blocks, post a screen capture of your blocks if you run into issues and want more specific advice.


i want to create contents of mail in textboxes rather than in lock section,to make app more flexible......

You need two more join puzzle pieces.      Try your blocks again after correcting.

???
have you seen this link?



thank you so much.It worked.Thanks a lot


Text-To-Speech Playback of a list of items


I have a List of items selected by the user on one screen.
Then it plays a  randomly picked item from the list on the main screen. ( which is working fine.)

Then repeat  speaking a random item for a user specified amount of times.( which is working fine.)

The Function that Randomly picks item from the list works fine. ( which is working fine.)

The problem is it spurts off all the list items so fast that it only starts the speaking each item, and you only hear the final word completely.

I have tried  "For Each", and Timers but not real success.

any other tips or suggestions would be appreciated.

--
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.

--
App Inventor is an event driven programming tool.  What this means is that it does things in sequence (more or less).   Your code is probably telling  the SpeechtoText  to fire on each list item...and guess what?  The Android can not keep up and you get collisions.

Why not instead,    create a string from the list items of the various lists, and only then let the app do a TextToSpeech on that string? 

--
CREATE A STRING. Completely do able,  i knew it was just something i wasn't seeing.  i'll give it a try.  and see if i have any improvements .
thanks for now.

as for code blocks, ive rearrange, deleted, and transformed this couple of functions numerous times trying combinations of things so  its a mess right now.
I'll keep it in mind though. 

--
I avoided run-on speech by arranging my speech texts in a queue
(list) serviced by the speech block that triggers when it finishes speaking
the current word.  
It was an attempt to have it "sing" a Gilbert and Sullivan patter song.
.
See the attached .aia file.






--

"Share via" button and avoid repeated questions

'm building a quiz multiple choice with 3 possible answers in checkboxes and I have two problems at the moment (screenshots attached):
1) I've achieved to link questions and answers but I don't want the questions to be repeated until the quiz is finished and I don't know exactly how to remove the questions already answered (I don't know if I have to remove every answer too because every one has its own list: Answers1, Answers2, Answers3). After the last question is answered I'd like the questions reappear from the beginning.
2) I'd like to have a "Share" button on the first screen ("Share via" bluetooth, whatsapp... to share the app) but all I've found on forums is this and it seems it has changed over the time. I don't know if it's possible on AI2.
I'll appreciate any help.

screen.jpg 표시 중

share.jpg 표시 중



1) How to pick a random item from a list without picking duplicates?



Thanks for your help, Taifun.
First, I'll try random items later (right now I have some technical problems...).
Second, looking at Packaging & Sharing Apps I see one option is to upload the app to a website, but the point is if it's possible to show a typical screen "Share via" to share the app the same way a photo is shared (I mean, I open a photo and I have the options to share it directly from my smartphone through bluetooth, whatsapp...). In order to do that with AI2 I don't know if there's a code as the one in the attached screen, not to send a text in my case, but to share the app I'm using. I also attach the way I'd like my first screen to appear with the "Share" button included.
Sorry for extending me and thanks again.

share.jpg 표시 중

first_screen.jpg 표시 중



you could store your apk in your Google Drive in a public folder and share the link to the file



Hi,
1) Now the questions aren't repeated but when all the questions pass it gets stuck on the last question because the list is empty (screen attached). The point is I want all the questions to start again and I don't know how. 
2) Related to "Share via" button, I've seen the component Sharing may serve to share the app (http://ai2.appinventor.mit.edu/reference/components/social.html), but I can't see the way I can share my app while using it. It must be something like the screenshot, but...

screen2.jpg 표시 중

first_screen.jpg 표시 중



1) store your questions in TinyDB and as soon as the list is empty, get the complete list from TinyDB again using the TinyDB.GetValue block
2) the Sharing component is to share images, sounds and texts, but not to share the app itself
what you could try is to store the apk file additionally in a folder of your device and then use the Sharing component to share that file.



Sorry for the delay... I haven't had the time to make any changes yet. I'll answer back shortly. 



Hi there! Here again after some days...
1) I've removed the questions so they don't repeat until the quiz is finished or the users click exit. Enough! 
2) The Share Via Button admits messages so I'll link the address to play store when I upload the app. Excellent!


message scheduler app

hello every body, does anybody knows how to schedule text message for future delivery in AI2?



You need to set a date in the saved message, and check the physical date via a timer.  In that timer, run through all of the stored pending messages, and if one matches the date saved with the message, send it.



You can not do that ordinarily in AI2.  AI2's email directs you to the email program on your device and requires manual intervention to actually send the email.   It is probably possible to send an email differently using a javascript or some other gimmick.

AI 2 apps do not run in the background, so, even if you use a javascript, your app that 'originates' the message needs to be turned on.

What you can do is save scheduling info in a TinyDb and have AI2  send the instructions to the email program on or after a set date.   However if you want the message to be sent on the 25th of the month and your app is not activated on the 25th, but is turned on on the 25th, the message will not be sent until after the 25th and depending on how you code; might not be sent at all.


Trouble trying to run Emulator

Trouble trying to run Emulator


1. I open aistarter (click on deskop icon)

   "Black" Box appeared as it should  (Last line is Hit Ctl-C to quit)

     Check in Windows Task manager and confirm aistarteer is running. 
  
2. Open existing project

    Connect > Emulator

   Pop-up box says "Connecting"  and then 'Helper?" which tells me to launch aistarter progra

 ~ but it is !

3. All antivirus and firewalls are switched off.



I can get the emulator to work only if I set aistarter to start at boot up, if I close it and then restart it then the emulator will not work.




Does this happen on all projects or just one?   The following are things that cause issues when compiling, creating an aia and/or running the emulator:

1)  You have coding errors in your blocks.  In the Blocks editor, look in the lower 
left for the yellow and red triangle icons.    If the red icon has a value larger than 0, 
you have a serious coding error.  Find the block in your code that has a red triangle and 
fix it.   Red triangles always inhibit creating an apk or running a project in the 
emulator or possibly creating an aia file.     Yellow triangles are more forgiving, 
however, sometimes, these need to be fixed because they trip an internal warning and 
you do not get a compile, so fix the yellow triangles too.

2) Your source file (the aia file) is larger than the 5Mb limit allowed in AI2 or you 
put images or other resources in your Media (resources) that you do not use in the app. 
 All the images and sounds in resources count toward the 5Mb limit.    You can program 
apps larger than 5Mb in the browser, but they will not compile and might not run in the 
emulator or the project may not save as an aia. If this is the case you need to reduce 
the size of your image and/or sound files.   Most image files can be made quite small 
by resizing them using a photo manipulation program on your PC to less than 50Kb each.

3)  You might have more than 10 Screens in your app.  AI2 becomes unstable when more 
than ten screens are used.

4) You might have set a Screen icon in the Designer Properties for your project that is too large. Use an image 
sizeof 48x48 px or 96x96px instead and only use jpg or png images.  *.ico files are not 
supported.

5) You did not code the entire project using App Inventor 2.   If you used one of the 
third-party AI2 clones,you might not be able to load a Project into the AI2 compiler or 
create an apk with the standard AI2.

6) If you incorrectly modified the project's Manifest files, you may have issues.

7)  Sometimes, if you have LOTS of Layouts on a single screen,  the apk might not 
compile.

8)  or the network you are using is overloaded (possibly a school network), or you have other applications running in the background, or your virus checker is doing a scan.  Sometimes, just trying a few minutes later will give you a more favorable response.

9) if you have BlueStacks on your home PC.  The emulator on AI2 cannot run unless BlueStacks is disabled and all of its processes are shut down.

10)  Are you using Sensor controls (except for the clock)?  Most Sensor controls or controls related to sms or the phone do not work in the emulators.  They need to be tested on a device.


Conocen algo para aplicar http://sloop.mit.edu/ en app inventor2 ? (Know something to apply http://sloop.mit.edu/ in inventor2 app?)

A software MIT (http://sloop.mit.edu/) that identifies lizards to study biology.

Has anyone researched this topic? Is there any way of identifying chart patterns by APP INVENTOR 2?

I hope so, Thanks Regards



App Inventor 2 is a beginners Android compiler.  "Is there any way to identify chart patterns by APP INVENTOR 2?"--- what do you mean by chart patterns?   AI2 has no Pattern Recognition tools... are you talking about statistical techniques like "simulate annealing" or pattern image comparison?    Probably VERY difficult with AI2.

What might be possible is that in certain circumstances, AI2 apps can "talk" (communicate) with online programs in a limited way and if the online program can accept data input, AI2 "might" be able to provide the input.

Is this what you are asking about?     There is no way for AI2 to communicate with sloop as far as I can tell.    You might contact this person:  http://sloop.mit.edu/contact   and ask.



Jorge sent an email:

Thanks Steve
Perhaps it is difficult to understand the question I asked in Spanish. All lizards have a drawing on your skin that can identify them as you would if they had fingerprints. The idea is to recognize a lizard by the picture of his back,
The idea is to recognize each pixel of an image on the back of a black and white lizard and generate algorism to compare with the data stored in a database.
regards Jorge

I understand completely Jorge.       That is called" pattern matching."    There is no tool in App Inventor that can do that.   You could try to write an algorithm that would examine an image an examine the pattern on the lizzard's back using Blocks and and try to have the algorithm  identify the species/genus based on the 'pattern'  but I believe it would be impossible with blocks.   What you are describing is a complex activity for a real computer; probably impossible on a phone for sure.


Element limit on apps?

Wondering if there's a limit of elements you can have to have a well running app. Or what would happen if it exceeded this limit.



no more than 10 screens
aia < 5 Mb
There are limits on the TinyDB ..it might be as small a 2 Mb of data or perhaps that limit is on a file loaded with File?  Someone will correct this if it is wrong I imagine.
Layouts ... too many and you are messed up.  How many? It depends on other stuff on your app
Some stuff depends on the device you design for, how much system memory it has (RAM)  and how much free space to store apps.

What would happen?    Your Android would melt?   Nah, nothing as exciting...your app would not be able to render an apk or perhaps an aia.   You might corrupt your project.The app would run fine for a short time, then the app would crash and you might or might not get Android error message

Exceed the limits and you will find out.  We have never had reports of the Android eating anyone.  At least not yet.



TinyDB is actually an XML file, about limits see this stackoverfow question http://stackoverflow.com/q/4925194/1545993



Thank you Taifun for the article... that article says an xml can be as large as anyone wants.   OK.   The reality is that over a certain size, the TinyDB is going to be un-manageable because of its size,  number of tags to sort, storage limitations on the device the app is loaded on etc.  Somewhere is the practical limit and that thread does say what the practical limit is.


Matchmaking Template or open source code

Has anyone see or experimented with a Matchmaking app either in App Inv or open source code?



The following explains in detail how to make just about anything:  AI2 free online eBook   http://appinventor.mit.edu/explore/ai2/tutorials.html   ... the links are at the bottom of the Web page.

Be aware The coated end of a match, known as the match "head", contains either phosphorus or phosphorus sesquisulfide as the active ingredient and gelatin as a binder.   Android devices have neither of these resources in any quantity, sot it is very doubtful AI2 can make a match.



Thanks for your reply. Sorry Steve I didn't make myself clear.  I'm referring to matching two people as in dating, but I have another purpose in mind and would like to not recreate the wheel.



Mark... you can do most things with AI2.  But it's up to you to determine how to code things, what algorithm you'd use to make a match, etc.  You'd have the same problems in ANY language.

What have you tried so far?