2017년 4월 21일 금요일

Saving canvas to gallery


Hi. I can take and edit a photo as in the tutorials, however I cannot seem to save it to the phone's gallery. Any thought please? Please look at the screenshot for more. I know I am saving it to the DB, but cant find a way to hit the gallery.

--
Use the GalleryRefresh method from the extension TaifunTools.








-- 

Need help making a counting game


Need the following counting game made meeting the following criteria if anyone could help would be great )

a. Welcome the player and ask the player for their name.
 b. If the player guesses incorrectly, the app should use the player’s name when stating the guess is incorrect: “Sorry, PLAYER’S NAME, that is not the correct answer.” 
c. If the player guesses incorrectly, the app should tell the player whether the correct number is higher or lower than the guess. 
d. Ask the player for the maximum number from which the player wishes to play. For example, instead of picking a random number from 1 to 10, ask the player what the maximum should be, and then pick a random number between 1 and what the player requested as the maximum. 
e. Keep a tally of the number of guesses it takes the player to guess the correct number. 
f. When the player guesses the correct number, using the player’s name, tell them congratulations and the number of guesses it took them.

--
We want you to have fun with App Inventor and learn to program.  Here are some resources to help you learn to use the AI2 tools  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  .

Most of what you need to code your guessing game is in the use of IF..THEN statements ...you can read about them here : Chapter 18. Programming Your App to Make Decisions

-- 
you can try to understand this and complete it as you wish


Hey thanks for the help. I forgot to mention that we're not allowed to use loops.

"Note that there will be no loop in your code because event handling will be used"

How would you go upon completing the program that way?

-- 
follow the recommendation of SteveJG...
you should do your home work yourself instead of asking here for someone, who does the work four you...
note: your teacher might read this forum, too...

-- 
Do you know what a loop is Tom?    If you had read the Inventor's Guide, you would have found this: Chapter 20. Repeating Blocks

Is there anything like that in Rudolph's example?

Do you know what an event handler is?   It appears you might not have read: Chapter 14. Understanding an App's Architecture yet.

What is in Rudolph's example are plenty of conditional statements  like these: Chapter 18. Programming Your App to Make Decisions
Are those loops?

-- 
This problems sounds like a High-Low Binary Search
where at each step you use the player's answer (higher/lower)
to adjust the upper and lower bounds of the range that
you think must include the player's (app's?) target number.
At each step, you suggest the center value of the current range, and
shrink the size of the range by half, deciding which boundary to
move inwards based on the higher/lower response.

-- 

Running flash content swf file in app inventor


Hello ..I wonder if I can run a swf file stored inside media in appinventor
I can add when screen initialize- call webview to got to Url-file://android_assets/file.swf
But it doesn't work .I think because webview doesn't support flash any idea to make it work?

--
is a mobile browser able to play that file?

-- 
No it doesn't .
-- 
well, if an Android browser is not able to play it, then a webviewer (which has a reduced functionality) also will not be able to play it

-- 
but i think you can convert swf to html file so you can run it

-- 

How to get the Speed of the device


i have another problem with the same project in this topic: 
I think, that i can get the speed of the device with the "YAccel" property of the AccelerometerSensor. But I was wrong.

Any of you guys know how to do that?

--
in fact, I think that you'll have to combinate the 3 axis to get the total speed, and I do belive that you will have to use the Pythagoras theorem, because depending on the slope of your phone, it won't be dected by only one accelerometer.

-- 
You are not using the built-in GPS.   To get speed (meters/sec) use the LocationSensor.LocationChanged event.
The GPS requires at least two satellite fixes (two LocationChanged events) before the 'speed' is calculated.  The LocationSensor Interval should be about 20 secs or more (smaller values will give the device a 'heart attack.'   This works best if the device is in a moving vehicle.. Yes, a moving bicycle, is a moving vehicle.

-- 
Yes, you're right, Steve.

--

Age Calculation - Age not reflecting correctly - aia attached.


I am trying to calculate age between two days. I've already checked one post and found the attached aia file which is almost working fine. It doesn't show the correct age when there is an increase in age and then a decrease. For ex: 1st time I give my age as 14/04/1987 - It gives correct age. Second Time when I enter some date like 01/01/1965. Here also I get the correct age. But for the third time when I give 01/01/1971 it doesn't show the correct age - The age is increased by 1 (Years = Years + 1 logic is triggered) of the previous age. 
Can you plz rectify the blocks... 


--
If you are asking for help, I recommend you to make it as easy for others to be able to help you ...
You probably will get more feedback then...

which means in your case post a screenshot of your relevant blocks...

To download the aia file, upload it to  App Inventor, open it, do some bug hunting for you, etc... this takes time, and most people will not do that...

-- 
This is a proper app to use ...

Also see the accompanying comments in this board.

Calendar time does not flow smoothly,
so don't be surprised at anomalies,
where time can seem to flow faster
in one direction between dates versus
the opposite direction, depending on
how you count it.

Date differences vary even by legal jurisdiction.

-- 
Sorry for that... Attached is the screenshot. 


-- 
I hope this helps you. I used text manipulation to do it. If you have a question, feel free to ask.


-- 
This version is easier to understand but not as accurate as the previous one. It may be off by a year some time. You chose which approach you like best. Thank you for giving me the opportunity to help.


-- 
Perfect Solution. 
Thank u very much :)

-- 

MIT app inventor, Arduino and bluetooth


I have established a connexion between my app inventor and my arduino thanks to a bluetooth. But I have a problem. I send a number or a letter to my bluetooth but when I received my letter with my arduino I have the number 255. I have 254 when I put a negativ number.  I have try to sand the number with 2 different way. The first one was : call bluetoothClient1.Send text and the second one : call BluetoothClient1.SendByteNumber.
Could you please help me ? 


--
I think the problem is in the way you are trying to read the data in your Arduino sketch.


The main difference is that I connect the HC06 Bluetooth device to the Arduino using pins D0 and D1, so it effectively across the Serial Monitor.

The slider reading ends up as an unsigned 1 byte number - maximum value 255.

I hope this helps

-- 
thanks for the help but it doesn't work... When I use pins D0 and D1 my Arduino receives nothing. 

-- 
Your problem suggests that your sketch is not right. There are other kinds of read like readInt etc.
please look at the FAQ in the Arduino and Bluetooth section for inspiration on how to do this. Q&A for Arduino and Bluetooth

--
Hi, try with text...
-------------------------------------------
// Juan Antonio Villalpando
// KIO4.COM

char val;
int LED0 = 0; // 
int LED2 = 2; // 

void setup() { 
Serial.begin(9600); // Aqui establecemos la velocidad
pinMode(LED0, OUTPUT);  // 
pinMode(LED2, OUTPUT);  // 
}

void loop() { 
if( Serial.available() )
val = Serial.read();

if( val == '0' ){ digitalWrite(LED0, LOW);}
if( val == '1' ){ digitalWrite(LED0, HIGH);} 

if( val == '2' ){ digitalWrite(LED2, LOW);}
if( val == '3' ){ digitalWrite(LED2, HIGH);} 
}


-- 
I have try but I have the same problem... 



-- 
Could you please post a screenshot directly? I cannot read your doc.

--

-- 
There are 3 things you can do:
1. Download some BT app that allows you to send direct commands, and see what you have to send to make it work.
2. Tell us more about your connection and device. What Arduino board do you have, and what BT-shield
3. Show all your blocks, also the ones that establish the connection.

-- 
You said you were recieving values, but they were not the right ones. Therefore it may be as simple as casting your text to char, as I found in my own little robot sketch:

void loop()
{
  //Receives commands from remote computer:
  if (serial.available())
  {
    int inByte = serial.read();
    serial.println((char)inByte);

    switch ((char)inByte)
    {
      //Actions:
      case 'f':
        sparki.moveForward();
        break;
      case 'r':
        sparki.moveRight();
        break;
...

-- 
thank you for your help. My Arduino  is a Arduino UNO and my BT-shield is from Sparkun and it is the model BlueSMiRF. I have check all my connection. 
It is all my blocks, I hope it could help you. 
I have try to char my text but it's doesn't work. My arduino doesn't receive anything but he goes in my void loop 

-- 
Your App Inventor code should work, therefor I think this is not the right forum to get help for your problem.
Just a few things though:

1. Before you send something to the Arduino, it is good to test if your Arduino is still connected and only send if true, but display an error if false.

2. In your sketch it strikes me as odd that you try to have two serial connections active, Serial and bluetooth. Then you try to read from the bluetooth connection, but maybe that is not the one which is active and I really doubt that this Smirf thing would allow you to have two connections.

I also Googled around a bit for you and found this thread, that maube can help you further. It has a link to example code that you may look at:
https://forum.arduino.cc/index.php?topic=62759.0

As a last resort, use a HC-05 or HC-06, I think they are much cheaper and a lot more people use it, it seems.

-- 

Thank you very much for your help!! 
I will try. And also thanks for the example code. 

-- 
I think it is necessary to use seral monitor from sketch arduino to see what is happening on arduino. You code one or many "Serial.print(data...);" to see if data ok before or after an action on arduino.
But the problem with UNO is that you have only one serial and if you use it with BT it's not possible to see serial monitor .
The solution, i think, for you is to buy an arduino MEGA (not expensive) because it has serial 0 (like uno) that you reserve for monitoring.
And, particularly, it has three additional serials (serial 1,2 and 3). So you can see what is happening on basic serial and you connect your BT on serial1.
I use an HC 06 like Ghica recommended you.


I join you an example to see what i mean.

                          String stringOne, stringTwo, stringThree;
//Initialisation des E/S et communication
void setup() {
Serial.begin(9600); //vitesse de transmission
Serial1.begin(9600); // liaison BT vers android
pinMode(LED_PIN13,OUTPUT) ;
pinMode(LED_PIN8,OUTPUT) ;
pinMode(LED_PIN9,OUTPUT) ;
                            stringOne = String("You added ");
                            stringTwo = String("this string");
                            stringThree = String();
//setupmyBlueToothConnection(); // appel de la fonction de configuration du module bluetooth si nécessaire
}

void loop() {
 

 

recevoir1();    // 1x = SMS pour carte BT  //  2x = SMS pour carte Hangar   // 3x = SMS pour carte DOMO

if (w==11)  {    reponse=11;  delay (100); envoyer1();                                   digitalWrite(LED_PIN8,HIGH);  } 
else        {                                                                                                         digitalWrite(LED_PIN8,LOW);   }          
if (w==12)  {    reponse=12;   delay (100); envoyer1();                                  digitalWrite(LED_PIN9,HIGH);  } 
if (w==13)  {    reponse=13;   delay (100); envoyer1();                                  digitalWrite(LED_PIN8,HIGH);  } 
             stringOne = "Sensor value: ";
             stringTwo = "  ";
             //stringThree = stringOne  + t1 + stringTwo + t2 + stringTwo + t3 + stringTwo + t4;                                         

}

//voids reception pour serial 1 2 et 3 de la carte BT
void recevoir1(){ if (Serial1.available()) { w=      Serial1.read(); Serial.print("recevoir1:"); Serial.println(w); Serial1.flush(); }   }                         

//voids envoi pour serial 1 2 et 3 de la carte BT
void envoyer1() { Serial1.print(stringThree);  Serial.print("envoi 1:"); Serial.println(stringThree);  Serial1.flush();  }

void setupmyBlueToothConnection() { // configuration du module bluetooth 
Serial.begin(9600); // set BluetoothBee BaudRate to default baud rate 38400 
Serial.print("∖r∖n+STWMOD=0∖r∖n"); // set the bluetooth work in slave mode 
Serial.print("∖r∖n+STNA=BTSlave_1∖r∖n"); // set the bluetooth name as "BTSlave_1" 
Serial.print("∖r∖n+STOAUT=1∖r∖n"); // permit Paired device to connect me 
Serial.print("∖r∖n+STAUTO=0∖r∖n"); // auto-connection should be forbidden here 
delay(2000); // this delay is required. 
Serial.print("∖r∖n+INQ=1∖r∖n"); // make the slave bluetooth inquirable 
Serial.println("Le module bluetooth est interrogeable!"); // affichage dans le moniteur série 
delay(2000); // this delay is required. 
Serial.flush();
//The end




--