2016년 12월 30일 금요일

RANDOM SCREENS


Is it possible to run the screens randomly?  

--
I mean if it can change it time the app runs for example one time 1, 3, 7 and another time that you open it 1, 5, 4...

-- 
You could set the timer to a random amount of time and close the screen when it fires.
Do you also want to open other screens randomly? In that case you could store a list of your screen names in the TinyDB and choose an element randomly when it is time to open another screen.
If neither of this is what you intend to do, then please clarify.


--
Why do you need so many screens?

Do you throw away one phone and buy another if you want to look at another photo?

-- 


Getting to the main loop of the screen


I'd like that my program could do a periodical action when a screen is active. Is there any kind of 'main function' for a specific screen? I mean, is there any main loop running everytime in background?

I'd like to check the timing of the system from time to time regardless of the screen where the user is at the moment.

I am developing an alarm and I'd like to check the time to activate the alarm or not.

--
The way to check things occasionally, is to use a clock with a long timer interval. However, when you switch screens at a moment that the timer did not fire, you must adjust the timer in th next screen. Or maybe, if the interval is short enough, that does not matter.

--
AI2 does not run in the background.

-- 

bluetooth Arduino


I developed a small app that imports data from Arduinothrough bluetooth,
the part of Arduino is working.

When I install the application I have a problem:
After I choose the bluethoot module from the phone,
the application stops responding on a black screen....

I am attaching my screen of blocks,
Is anything wrong?



--
Here is something to try.
Perhaps have the Clock1.Timer Enabled to false initially in the Designer.
Below the BlueToothConnect.Address procedure you can enable the timer.

-- 
Before this project worked great,
Now it is not working on three different phones,
I have replaced the bluetooth module, Arduino twotimes,
because I thought that the problem was in this,
but then I tried it with a PC and it works Arduino,
everything hangs when I choose the phone the bluetoothmodule.
I attach the set clock of my program,
some idea?
has anything changed in the app inventor ofbluetooth data management?

-- 
sometimes it helps to look around a little bit...
before using the ReceiveText block make sure, there is something to receive
for example this solution, which was discussed yesterday: I can't quite figure out how to get this right

-- 
Your timer settings seem pretty fast. How fast is the Arduino sending data? Indeed, if you get the next timer event before you are finished waiting for the previous one, the app will choke. It will help in any case to experiment with longer wait times of the clock.
If your message received from the Arduino is short, then Taifun's method will work. If you are receiving long messages, you must use the number of bytes to receive block, collect them in a global variable as buffer and check whether you found the end of message and only then dissect what you have.


--
I have done many tests,I write the results:A) Arduino UNO, HC-S04 sensor and bluetooth module are new and they work fine with the Serial Port of PC

B) I have always done more tests with the same simple sketc arduino, this:

#define echoPin 7 // Echo Pin
#define trigPin 8 // Trigger Pin

int maximumRange = 200;
int minimumRange = 0;
long duration, distance;

void setup() {
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
}

void loop() {
 digitalWrite(trigPin, LOW);
 delayMicroseconds(10);
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10);
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 distance = duration/58.2;
 if (distance >= maximumRange || distance <= minimumRange){
 Serial.println(" ");
 }
 else {
 Serial.println(distance);
}
  delay(100);


C) I have always used in the  test, the clock setting the TimeInterval is 1000, with check of TimerAlwaysFires and TimerEnabled

D) I have set Bluetooth client in all tests as picture attached Bluetooth.pngTest 1 (blocks, picture Test 1.png)-Once You have selected the Bluetooth module is rare that continues;-The rare times (once out of 20 times) I had
 
1) turn off the phone
 
2) 
turn off Arduino
 
3) Turn off bluetooth- That one time worked, the numbers were not in real time, is blocked and then gave a series of about 10 seconds before numbers

Test 2 (blocks, picture Test 2.png)
- As soon as I open the application appears to me
"Error 505: Not connected to a Bluetooth device"- I continue and I click on the bluetooth module is connected but no data appears(Immage attached Error.png)- It never stops, but never gives the data.What do you advise me to do?The part Arduino works, it would seem that app inventor(or I) has problem in connexin bluetooth data.Can you send some of your example?









-- 


Test 2 (blocks, picture Test 2.png)
- As soon as I open the application appears to me
"Error 505: Not connected to a Bluetooth device"
- As soon as I open the application appears to me"Error 505: Not connected to a Bluetooth device"



most probably, this is, because your clock is enabled from the beginning
you should disable your clock end enable it after the connection has been successful
Taifun

--
I have not selected Timer Enabled and active afterblutooth connection,
Now tests have improved. The phones now are connected to bluetooth module
but there are no incoming data (numbers in centimetersfrom Arduino)
is just the Bluetooth setting which I am attaching?
What I can fix?
Someone can show an example .aia?



--
Thee are many examples of people successfully connection Arduino's to AI2 using Bluetooth, so somewhere there must be a bug in your setup.
What you can do to find out is to use another app like Ardudroid, to find out what your Arduino is really sending.
Also, show your relevant blocks as they are now, or attach an .aia



--
Something else: you assume that the text you receive will contain a ?
What if there is no ? I do not see it written in your sketch.
So, you will not see anything.
What you should do, is create a new label, called debugLabel or similar, and show all received text in it. You can see then what your Arduino sends and adapt your app as needed (or the sketch, if needed)



--
I tried to make a sketch for my Sparky robot car (which has also a proximity sensor), similar to yours. The main difference is that my sensor sends out integers instead of floating point numbers, but I think that this does not differ too much.
Here are my blocks:
This should work for you too. Because the Arduino is much faster than the AI App, you will usually get two values, which are displayed on two lines in the label. You could make the timer interval shorter, or you could chop the second value off (look at the text blocks, for example "split at", use /n as at value. You would get a list, of which take the first element and display that.

I made the text of the listpicker "connected" when the connection succeeds, that is nicer. Actually, you should have a disconnect button and disable the listpicker when connected.

-- 


AI Companion-The Companion you are using was built for different instance of AI


Hello, I have always been able to connect to my appusing AI Companion. But today, I encounter this problem
"The Companion you are using was built for different instance of App Inventor. To obtain the correct companion look on the App Inventor screen under Help->Companion Information menu."
I then updated my app from 2.35 to 2.36 but still have the same problem.

--
see here Instance problem and try again

-- 
Is this still happening?

-- 
No. It's working now. Thanks

-- 


Instance problem


We have a school lab of Mac OSX computers which my 2 blocks of students share, one in the morning, one in the afternoon. My first block of students didn't have any problems using the emulator in the morning. However, my second block of students in the afternoon all had problems running their programs in the emulator. The error is:

"The Companion you are using was built for different instance of App Inventor. To obtain the correct companion look on the App Inventor screen under Help->Companion Information Menu".

Students in both classes don't have issues testing using their Android phones/tablets, just my second class using the emulator.

I have tried reset, and hard reset, and nothing has worked.

Is there a problem with multiple users on the same computer running the emulator? Can there be 2 different logins accessing the emulator program on the same Mac computer?

--
I believe your problem may be related to the release we just put out this afternoon. I have backed the release out until I can do more debugging. I apologize for the inconvenience.

--
Thanks for the quick action and quick reply. Both our classes were able to launch the emulator now in our Mac OSX lab.

-- 


Using oauth api


thank you very much for your working . Please help me. I'm working to do an app that contain oauth api. How can i get access token. There is no block in your https://puravidaapps.com/oauth.php page. Please help:(



--
in addition i have an client id and secret

-- 
read the large green box on the bottom of that page https://puravidaapps.com/oauth.php about how to get the source code. thank you.

-- 

There is a bug in version nb148


There is a bug in version:
Build: April 24, 2016 Version: nb148
When you load a project that has the size of font of a different checkbox to 14.0 resizes the height of the checkbox component pixel image attached.
I changed the height of all checkbox to "automatic" but when I save it and Reloading the project again resize all checkbox to pixels.
I hope to settle it soon.

checkbox.png 표시 중

-- 
It is very strange,  I've changed the size of the font to 14.0, and I've changed the Height as "Auto" again, I have closed the browser and I've  reloaded the project and AppInventor again change the height of the checkbox to 14px instead of "automatic".

-- 
It works correctly for me on Windows 10, Chrome browser.
I set checkbox height to 14, saved the project.
Then set checkbox height to automatic, saved the project.
Closed the browser.
Reopened the browser.
The checkbox height was still set to automatic.

-- 
Try again.
I think you accidentally may have set the checkbox height to 14 when you were trying to set the FontSize to 14.

-- 
This is indeed an issue. We recently changed the system so that when you set the font size it would change the height of the checkbox. We will look into figuring out what the right thing to do is...


-- 
It occurs when I load the project in the browser, AppInventor resizes the checkbox another time to pixels.

-- 
We just deployed nb148a which should fix this issue.



-- 
Thank you, when I have time I try it and you commented. Greetings.

--
Perfect!!

-- 

Recorder Saves file with extension *.3Gp but adds another "." after extension


Recorder saves recorded message with and extension  nameofsong.3gp and sometimes as nameofsong.3gp. with a "." after 3gp

I am using Lenovo Laptop with Windows 10 with a Samsung Tablet SM-T230NU running Android Vers 4.4.2.
Here is the project Rec3GPFile.aia

Also Plays previously recorded audio file sometimes.

Thanks for your support.
Any reason why it does that?


--
use this test project How to use the Sound Recorder and let us know, if you get the same issue on that device
-- 
Thanks a lot. That worked. Frank

-- 


Google or MIT


If i ask a question here, I usually get a great answer. I'd like to know, am I usually answered by MIT or Google employees?

--
MIT and forum community members.

--

APP INVENTOR 2


I'm currently doing some coursework for computing on app inventor and i was wondering when app inventor 2 was first introduced to the public or when it was first released coming from the original program using javascript 

--

Problem creating a folder


i us 6-12 imagepicker, Want to save the image in a folder  full size image. the images show on screen on smalL canvas.
i us tinydb call storvalue tag as "\DCMINI\imag2.jpg"
Icanot find the Folder un the tablet.

--
TinyDB can't create folders, TinyDB is to get or store values in the TinyDB database

-- 
The image from the imagepicker is saved as sized of canvas.(small)
I need the image to be saved as original size, How can I do this?

-- 
use the image picker together with the Copy block of my File extension to copy the image to that folder https://puravidaapps.com/file.php

-- 

I wanted to create an app for my org which picks a specific PDF file from a list


Please guide me with this I want to store pdf files in web db as it will be updated every now and then I want to pull the updated data on web veiwer of my app and provide an option to store the doc in phone if the user wants.

activity starter open another appinventor app


Can I With Activity Starter Open Another AppinventorApp

--
yes, see here Using the Activity Starter

-- 

PROBLEMS WHEN I RUN THE APP


I am done making the app. It´s like a game and you have to pass screens. Firstly, I installed on Android 4.2 and in the second screen the app stop running. So I try in Android 5 and the app is working but instead of going to the next screen each time when you press the button, once in a while (normally after 2 screens) is coming back and you have to repeat the same process. 

What can I do for correct this?

--
see here how to switch screens correctly
The recommended method of switching screens in App Inventor

-- 
Thanks so much. The problem is how to change the screen. 
I read the tutorial but I don´t have a manage screen so I don´t know how to fix it. 

-- 
Are you using Clock component to inspect data and switch screen? If so, maybe that's the issue.
Also, it would help if you post screenshot of your blocks.

-- 
Thanks so much. 
I have 20 screens like these one and I know I should use close blocks but I don´t know how.

Captura de pantalla 2016-04-26 a las 7.27.39.png 표시 중

-- 
use Screen1 as manager screen
in the button4 event use the close screen with value block together with a text block "calendario"

-- 

I have 20 screens like these one 
then you should also read this Building apps with many screens

-- 
I am not using any clock 

--
Thanks so much for all your help. I will try to fix it :)

-- 


Bluetooth Problem with Arduino


I made my project to conect and setup arduinos PWM-s with BT app made in MIT APP INVENTOR 2.

When i tested it on my phone with android 5 (LG G2) everything works perfect.
Data string : *83,13,58,37,2016,4,25 is readed from arduino and interpreted by app

When i Upload app to tablet HP on android 4.1. i get error 
Data string from arduino readed by app looks:
83,13,58,37,2016,4,25
*
When I connected arduino by USB cable and open rs com get 
*83,13,58,37,2016,4,25
but app get
83,13,58,37,2016,4,25
*
Same error with phablet woo on android 4.2.2

I don't know how to solve this problem.
Becouse in app i have to make list from cvs (separeted by , ) i got an error   and the app is closing

--
*83,13,58,37,2016,4,25
so the question is, where is the star coming from?


Becouse in app i have to make list from cvs (separeted by , ) i got an error   and the app is closing

which error do you get? you might want to remove the star before converting the string into a list

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

-- 
I have attached the basic procedure.

With android 5 it works ok.
but with 4 get an error.

Best regards

arduerrorpng.png 표시 중

--
the star is answer from arduino it shuld come at the begining of the string than 83 is a code of the procedure in arduino to send time and date in dallas chip

when i send 40,......................... i change date and time in ardu...

-- 
The string from arduino :
*83 - procedure to send date from arduino  (I am asking ardu 83 it answers *83)
procedure,hour,minute,second,year,month,day

-- 
Looking at your AI2 blocks, I see a problem with your send/receive timing.

You send an 83 to Arduino when your AI2 button is clicked, but then you IMMEDIATELY try to 
receive data from the Arduino, without giving it a chance to build a response and send it to AI2.

I suggest moving the AI2 reception blocks to a Clock timer routine,
activated after the 83 is sent to Arduino, non-repeating and self-disabling.

Also, I suggest investigating the use of a Bluetooth delimiter byte to help distinguish between the start of one message and the end of the previous message.

-- 
I think that you are right. Probobly on Android 5 works becouse i have BT 4 Module and he is fast enough and it worked.

I'll try with timer, and give you a note.

-- 
Ok . So I have tried with Timer. But I think that it wasn't a problem.
It solved problem with bad data read (not full path....) but not that the text receved from arduino for android 5 is interpreted exactly as it was sent from arduino, but in android 4 get same error.
Just looks like "*" is interpreted like different list of data not as one string. which is strange because of Call(BT)Bytes.AvailableToReceive

-- 
I managed to solve the problem

Now it works, but as you see it was little complicated.

Solved.png 표시 중

-- 
Are you turning this in as an assignment?

If so, there are some things in your blocks you will be challenged on.

The first ELSEIF branch in your timer looks very fishy.
You are comparing a true/false comparison result value against a blank text?
How do you expect that to turn out?
And what do you do if it is true?  Assign something into itself?

-- 

Chrome unresponsive when opening App Inventor


I'm having trouble now with opening App Inventor.  When I open App Inventor, I get a pop-up that tells me Chrome is Unresponsive and I have the option to Kill or Wait.  I have tried this on 3 PCs( 2 desktops and a Laptop), all working last month. After several attempts to just open the App inventor website, I finally got to an error that the server was busy... This actually helped(I thought), because now I could select other projects and open them.  I then deleted the project that was becoming unresponsive when opening App Inventor.  I then restored my AIA file.  App Inventor then crashed from importing my AIA file.  This file was working fine for over a month and the APK is running on over 200 fellow workers devices.  I only tried to open it to make some slight changes...  Any suggestions, since now I'm back to the Unresponsive pop-up after restoring my AIA file.  I'm stuck and can't get App Inventor past the Wait or Kill Pop-up.

Hopefully someone may have a suggestion for me... 
  
Thanks

PS- I've rebooted router, modem,and PC... and tried my laptop on other networks

 Unresponsive.jpg

--
I also got this and sent the report...
===================
Ooops! We tripped on a Bug!
Please help us by telling us what you were doing at the time this happend. We have already included some technical data with this report. If you do not submit this report, nothing will be reported to us. If you do submit a report, your comments along with the technical data will be sent to us.
Thank you for your help in making MIT App Inventor better!

notes = Browser: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36
foundIn = nb148a
faultData = com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot read property 'ReplMgr' of undefined
projectId = -1

-- 
For large projects you might need some patience and click the "Wait" button several times to get a large project loaded
In case you are using loads of images, follow the recommendations here Using Images with App Inventor


Also you can try an offline App Inventor version, which runs directly on your computer.

Let me recommend you to use AI2 Ultimate, you can download the correct version (32 or 64 bit) for your computer here https://sourceforge.net/projects/ai2u/files/ai2u%203.6/Installer/
For questions about AI2U, please ask in the AI2U forum here https://groups.google.com/forum/#!forum/ai2u

-- 
The ReplMgr reference suggests that you were connected to the emulator at the time when you tried to open that project.
If you were, that probably increases the amount of work needed to open your project in the browser.
Shut down your emulator before trying to open that project.

Also, a fresh lightweight browser like Maxthon with no add ons and good bandwidth might help.

You might try to load your .aia onto thunkable.com to see if it's a server load problem.

-- 

For large projects you might need some patience and click the "Wait" button several times to get a large project loaded
In case you are using loads of images, follow the recommendations here Using Images with App Inventor



Not that many images...  AIA file is 365K.  After more reviewing, I think my issue is 10 screens...  Didn't realize I had that many. 


Also you can try an offline App Inventor version, which runs directly on your computer.

Let me recommend you to use AI2 Ultimate, you can download the correct version (32 or 64 bit) for your computer here https://sourceforge.net/projects/ai2u/files/ai2u%203.6/Installer/
For questions about AI2U, please ask in the AI2U forum here https://groups.google.com/forum/#!forum/ai2u



I will have to look into an offline version,  Thanks for the suggestions!!!

-- 

The ReplMgr reference suggests that you were connected to the emulator at the time when you tried to open that project.
If you were, that probably increases the amount of work needed to open your project in the browser.
Shut down your emulator before trying to open that project.



 emulator was not open 


Also, a fresh lightweight browser like Maxthon with no add ons and good bandwidth might help.



I think my bandwidth is OK... :)  See attached jpg.
Tried Thunkable... Same issue.

***********  MAXTHON ROCKS  !!!!!!!!!!!!!!!!! *************

I was able to load my backup AIA and my other checkpoints.  Now I just need to combine a couple of my screens to reduce the number of screens.


You might try to load your .aia onto thunkable.com to see if it's a server load problem.



Thanks you and Taifun for your suggestions!!!!   This app is about 3 years in the works and has been a major undertaking.  I know I need to move up and learn Eclipse, but I just don't have the time right now.

Looking forward to extensions!!!

SpeedTest.jpg 표시 중

-- 
How do you mark a topic Completed?

-- 

Problem with converting Grads to Degrees


I just started my trip with MIT AI2. I'm trying to do some Geodesy tools to help my friends on geodesy studies.
Okay, but back to the topic. I have some problems with conversion Grads to Degrees. They are both angle measuers but in degrees we have 360 degrees, 60 minutes and 60 seconds, and in grads we have 400 grads, 100 centygrads and 100 myriograds.
Firstly, how do you can enter a maximum number (eg 100)?
Secondly, how to do if the result shows a number greater than the maximum number of minutes (60) added to the previous field (degrees) one degree, and take away the minute appropriate value?

1.png 표시 중

--

Firstly, how do you can enter a maximum number (eg 100)?

after entering some data, then do some data validation using an if statement

if entered data > 100 
then display a message "max. value is 99"
else do the calculation


 Secondly, how to do if the result shows a number greater than the maximum number of minutes (60) added to the previous field (degrees) one degree, and take away the minute appropriate value?

you might want to prepare an example of a conversion and how the correct result would look like, also the formula of the calculation probably can help us to help you

-- 
Ok second thing I already did by if/then/else :) But i have problem still with first.
It's hard to do, because:
1) i cant find display a message,
2) i have 3 different text box and i think it will be impossible to display 3 messages at once

I think about formula that you cant type in text box more than eg 360, 60 etc

-- 
use a notifier component

if textbox1 > 100
then Notifier.ShowAlert "textbox1 must be < 100"
else if textbox2 > 360
then Notifier.ShowAlert "textbox2 must be < 360"
else if textbox3 > 60
then Notifier.ShowAlert "textbox3 must be < 60"
else do the calculation

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  
How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of AppInventor, then try something and follow the
 Top 5 Tips: How to learn App Inventor

You will not find a tutorial, which does exactly what you are looking for. But doing the tutorials (not only reading a little bit) help you to understand, how things are working. This is important and this is the first step to do.

-- 
THANK YOU VERY MUCH! You are incredible!

-- 

App inventor 2 help with blocks for buttons please.


I have a canvas that shows a university campus which has a ball on each building, i would like to create a code where i can click on the ball and at the top of the screen it shows the amount of computers available in each building, and then i need to create a cancel button that adds 1 to the computers available but can only be clicked if you click reserve first, and also a reserve button which takes away 1 from the computers available. I am having great difficulty doing this and would really appreciate any help. I find the blocks way too hard to do because i have not used or been taught about this software at all. :(

--

 I find the blocks way too hard to do because i have not used or been taught about this software at all.


A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  
How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of AppInventor, then try something and follow the
 Top 5 Tips: How to learn App Inventor

You will not find a tutorial, which does exactly what you are looking for. But doing the tutorials (not only reading a little bit) help you to understand, how things are working. This is important and this is the first step to do.


--