I cannot make my App to work

Hi Chris
I am learning the APP inventor because I am going to start giving classes in high school and I was asked to give this subject.
I am taking a course in Coursera, but I do not understand everything they are teaching.
I had followed their instructions to make an app to set up an Alarm and the code does not work.
I do not know what to do in order to see what was wrong with the blocks, is there any way to see what the problem was?

AlarmClock.aia (1.2 MB)

Hello Ilya

I will take a quick look. We do find that external course providers tend to lag behind the releases of App Inventor/Android.

Right, first thing to note is that this tutorial is not a good example of what App Inventor can be used for. The reason is, An alarm that spans hours requires the App to stay on for that length of time, which can be done but it will drain the battery. Making a custom alarm requires access to Android Background Services but App Inventor does not support this. Another issue is that the Clock Timer lacks accuracy - it is suitable for many purposes but for accurate timing my colleague Anke has created an extension.

However, we can test over a few minutes without concern for the battery :slight_smile:
… the .mp3 might be too big for the Sound Component so I substituted the Player Component just in case.

Basically, the code works like this:

  1. Get the Alarm time set by the User
  2. Get the Time Now
  3. Convert both times to milliseconds (the unit used by the Clock Timer)
  4. Subtract Time Now from Alarm Time to get the Duration of Time until the Alarm should trigger - set that value as the Clock Timer Interval and Enable the Clock timer.

So, I can see nothing wrong with the code logic, but I can confirm it doesn’t work with the Companion. I simplified the code and still no joy :roll_eyes:

Doesn’t work as an APK either. Must be something obvious I’m missing. I have tested my own simplified code. “DoIt” correctly shows the ClockTimer should tigger in 120000 milliseconds (2 minutes). The Clock is triggered at the correct time - we know that because the Label text is changed from the Alarm time to the “Alarm not Set” message. Yet the .mp3 is not played (I have verified it is OK) and even vibrate fails to happen.

My code blocks:

My Project (most basic): AlarmClock_2.aia (351.1 KB)

Well, I have tried taking the sound functions out of the Timer block and put them into a procedure but still no sound/vibration is played when the Timer is triggered.

It’s getting late (I’m in the UK), so I will assign this puzzle to a colleague. :upside_down_face:

We want you to learn to code with App Inventor Ilya. This note does not provide advice about your Project specifically but might provide a different way to look at and learn to code with Blocks.

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 .

Also MIT’s tutorials and other resources may help you MIT App Inventor >> Teach and http://appinventor.mit.edu/explore/resources may help you design YOUR curriculum.

Also look here http://kio4.com/appinventor/index.htm and here http://www.imagnity.com/tutorial-index/ for more tutorials.

If your course explanations are too difficult and you cannot get help from that course, the above resources and FREE course mentioned may help you develop the skills necessary to teach the computer course.


1 Like

Little test, no alarms, no clocks. Tested Sound and Player components. The .mp3s are still not played! The App Inventor IDE does play them, and they are within the Android spec.

Mono/Stereo 8-320Kbps constant (CBR) or variable bit-rate (VBR)

Alarm-ringtone.mp3 and Twin-bell-alarm-clock-sound.mp3 are both 192kbps 44100Hz

My Test, with a couple of extra files:
PlaySound.aia (1.7 MB)

Evan - am I getting something very basic wrong? Is it the path to the files that is a problem?

They all work for me Chris…using your aia


Yes, everything works fine. I have tried almost all audio formats and sample rates in the past few years. No problems, so it won’t be because of that. Which device and which Android version is it (tested with Companion or APK)?

Companion and APK. Samsung S8 Android 9 (all updates). Would be interesting to know Ilya’s device spec too.

I tested on a Galaxy Note 8 (Android 9) that is almost identical to S8.

Either the device is in silent mode or the speaker is broken. :wink:

Does Hello Purr work for you, if using both Sound and Player? I wasn’t able to get this to work in an Android 9 emulator, but it was also the case that Hello Purr didn’t work in spite of it being dead simple. Everything worked on my Google Pixel running Android 10.

Can you play the MP3 files through your phone’s default music app?

1 Like

:smiley: Fixed with a Bill Gates! (shutdown, reboot device)

Simplified Alarm Project works too, so hopefully it will work for Ilya too and Steve has directed her to more appropriate tutorials etc.

What did not work?

  • Did the screen change at the requested time?
  • Did you hear anything? (Check the volume control?)
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.