# Android

Apps

Here’s a list of the apps that I have developed to date and where to find them on Google Play.

It seemed to me that learning to develop smart phone or tablet apps had a steep learning curve. Then I discovered MIT App Inventor. Unfortunately at this time it only works for ANDROID devices. But MIT predicts that APPLE iOS development will be possible “real soon now.”

Here’s what an MIT website says about App Inventor …

**“Anyone Can Build Apps That Impact the World.”**

“**MIT App Inventor** is an intuitive, visual programming environment that allows everyone – even children – to build fully functional apps for smartphones and tablets. Those new to MIT App Inventor can have a simple first app up and running in less than 30 minutes. And what’s more, our blocks-based tool facilitates the creation of complex, high-impact apps in significantly less time than traditional programming environments. The MIT App Inventor project seeks to democratize software development by empowering all people, especially young people, to move from technology consumption to technology creation.”

I played around with App Inventor a bit, going through a few of their tutorials. I was impressed with the it’s ability to allow me to easily interact with the phones hardware and other features. I could examine and manipulate data from my phone’s built in accelerometer, camera, wi-fi, audio, location, internet and other features.

THE BEST IS THAT WHEN I’M FINISHED I’LL HAVE SOMETHING REAL TO SHOW FOR MY EFFORTS … A BRAND NEW APP FOR ME TO USE MYSELF AND (IF I WISH) SHARE WITH THE REST OF THE WORLD.

It reminds me of HyperCard, a programming environment included free with all new Macs from the mid 80’s until the mid 90’s. It allowed me to build sophisticated Mac apps based on the idea of dragging and dropping a library of objects like buttons, fields, graphics, etc. to set up the user interface. HyperCard objects were coupled with a scripting language, HyperTalk. I did a lot with it and was really sorry to see no it longer supported.

**App Inventor, for me, is the HyperCard of the 21st century.**

I learn new computer applications best by getting acquainted with the basics, then choosing a “real” project, acquiring new features as I need them. So I asked myself, what to do that would amuse me? Below are descriptions of the seven apps that I have written so far, now posted on Google Play if you would like to download them to try on your (Android) phone.

**List of all seven of Dan’s Apps now published on Google Play here …**

https://play.google.com/store/search?q=pub:Dan%20Davidson&c=apps

**ALL THESE APPS ARE FREE AND DO NOT CONTAIN ADS.**

**TipRight** is a simple, quick, easy to use, one screen restaurant bill calculator. It is designed for portrait mode cellphone use.

Find on Google Play …. https://play.google.com/store/apps/details?id=appinventor.ai_dandvdsn.TipRight

– FREE, NO ADS, NO PERMISSIONS

– Intuitive interface

– Built in keypad allows quick entry of bill amount,

– Buttons for 10%, 15%, 20& and a button that will pop up a field for entry of any dollar amount.

– Buttons for split of total bill from two to six people plus an additional botton that will display a field for an arbitrary group.

**Rocket Rangler i**s a game / science education app that simulates a rocket and satellite moving in space, in the vicinity of the Earth, subject to the “1/r^{2}” law of universal gravitation and Newton’s laws of motion.

Find on Google Play …. https://play.google.com/store/apps/details?id=appinventor.ai_dandvdsn.ORBIT_600

**HERE’S HOW THE GAME WORKS … ** You can directly control the rocket, but not the satellite. Your mission is to

- Pilot the rocket to pick up the satellite by passing over it.
- Release (DROP) the satellite into a stable, “near Earth” orbit.
- You must avoid crashing the rocket or satellite into the Earth or allowing the satellite to drift off screen.

**NAVIGATION** You manipulate the rocket with a joystick. The more it’s displaced, the greater the rocket’s acceleration in that direction. To slow or stop the rocket you must accelerate it in the direction opposite to its motion (decelerate). The gravitational force acts at all times getting weaker the farther the rocket is from the Earth.

**GAME LEVELS** There are four game levels: Ensign, Lieutenant, Commander and Captain. With each increase in rank, the game’s objects move faster and the joystick becomes more sensitive.

**SCORING** At the end of any game a score is awarded based upon your rank, manipulation of the rocket, fuel remaining and satellite drop in close orbit around the Earth. *(This game was developed using MIT App Inventor.)* * *

**RAND****OMLY** is three apps in one, all based on random choice.

Find on Google Play …. https://play.google.com/store/apps/details?id=appinventor.ai_dandvdsn.Randomly

CHOOSER, the random list item picker, has an editor letting you compose and internally store any number of lists as well as importing / exporting them as .txt files to the download folder of your device.

DICE, as the name implies, animates randomly throwing two dice. If sound is turned on, it will call out the common name for the combination (snake eyes, etc.) Also DICE keeps track of the number of times any particular combination is thrown.

COIN animates a heads or talls toss. Sound on calls out the toss and simulates a coin rolling on a table. A counter keeps track of the number of heads and tails called.

**L****inear Explorer**

Explore the relationship between the equation of a straight line in slope-intercept form (y = mx + b) and its graph.

Find on Google Play …. https://play.google.com/store/apps/details?id=appinventor.ai_dandvdsn.linear_Explorer

Change the graph by dragging the red or yellow “ball” to move the end points of the line segment.

Linear Explorer immediately displays the equation of the resulting line in slope-intercept format.

Arrow buttons allow fine-tuning the equation one pixel at a time.

Ask yourself “What happens if …?” questions.

- What happens if the line parallel to the x axis? The y axis?
- What does the equation look like when the slope is 1?
- What are the x and y intercepts of a particular line?

And so forth …

A BASICS button pops up a quick review of slope-intercept concepts.

A READ button displays full instructions as well some information regarding the development of the Linear Explorer app.

**Decimal to Fraction Explorer** Explore how a decimal number (less than 1) converts to a fraction.

Find on Google Play …. https://play.google.com/store/apps/details?id=appinventor.ai_dandvdsn.Decimal_to_Fraction_Explorer

To use Decimal to Fraction Explorer, just enter the decimal you want to convert, then press “Compute Fraction.”

After conversion, in addition to the fractional equivalent, a pie chart graphically displays the result.

One main difference between fractions and decimals is that fractions tend to be simple expressions of ratios of whole numbers while decimals represent equivalent quantities by using decreasing powers of 10. Surprisingly, longer decimal numbers sometimes convert to quite simple fractions. For example, the repeating decimal of 0.33333… converts to the fraction, 1/3. The decimal number, 0.0937 converts to the fraction, 3/32 and .5625 converts to 9/16.

Decimal to Fraction Explorer uses a recursive calculation that begins with a very rough guess then refines it with a large number of substitutions checking to see if the new guess is any closer. Because this algorithm takes processing time, we have to call it quits after a while when we decide the guess is good enough. This may add an additional small discrepancy between the decimal and its fractional equivalent.

The bottom line of text in this app shows the (mostly very small) difference between the decimal you entered and the fraction the program generated (when recalculated as a decimal by dividing the numerator by the denominator). This app is free and contains no ads!

**Flicpool** FlicPool is a pocket billiards-type game.

Find on Google Play …. https://play.google.com/store/apps/details?id=appinventor.ai_dandvdsn.flicpool

Flicpool is pretty open-ended. You make up the rules. Justuse a finger to flick the cue ball (white) at the speed and in the direction you hope makes it strike another ball (or balls), one of which (also hopefully) will land in one of the pockets.

Sink a ball and the active player (yellow background) receives 1 point.

BUTTONS

[PLAYER 1] or [PLAYER 2] Change players any time by pressing on the [PLAYER 1] or [PLAYER 2] button at the top of the screen. The active player has the yellow background and receives the point for any ball sunk.

FIRST BOTTOM ROW

[NEW] Starts a new game. The score is reset to zero. The cue ball can be moved to any desired location by tapping on the “pool table

[RACK] Same as [NEW] but keeps the accumulated score. To use when all balls have been cleared but you want to game to continue.

[BACK UP] You might decide on a game where you have to specify the pocket to sink the ball. This button will retrieve the mis-shot ball, place it on a random spot on the table and subtract 1 from the score of the player. [READ] Displays instructions and explanations regarding the app’s operation.

SECOND BOTTOM ROW

[Friction Slider Sets the deceleration of the balls due to “friction.” A setting of 10, all the way left on the slider is greatest friction. All the way to the right, value of 0 simulates a frictionless surface.

[QUIT] Exit the app or start a new game.

THE “PHYSICS The laws of FlicPool physics are quite simple. A struck ball will continue at the speed of the ball hitting it, in the same direction. The striking ball also continues in the same direction at one tenth of its original speed. It pretty much replicates exchange of kinetic energy of two almost perfectly elastic objects. I haven’t taken off-center collisions, spin, conservation of momentum and stuff like that into account. Bounces off the sides of the table are treated as perfectly elastic collisions, speed stays the same, angle of incidence equals angle of reflection.

**“Poo Pool” is a toilet-themed version of the FlicPool app described above (pocket billiards).**

Find on Google Play …. https://play.google.com/store/apps/details?id=appinventor.ai_dandvdsn.Poo_Pool

[PLAYER 1] or [PLAYER 2] Change players any time by pressing on the button at the top of the screen. The active player, the one who accumulates the score, has the yellow background.

FIRST BOTTOM ROW

[NEW] Starts a new game. The score is reset to zero. The scrubee can be moved to any desired location by tapping on the “bathroom floor.”

[RACK] Same as [NEW] but keeps the accumulated score. To use when all poops have been cleared but you want to game to continue.

[BACK UP] You might decide on a game where you have to specify the pocket to sink the poop. This button will retrieve the mis-shot poop, place it on a random spot on the table and subtract 1 from the score of the player.

SECOND BOTTOM ROW

[Friction Slider] Sets the deceleration due to “friction.” A setting of 0, all the way left on the slider is no friction. All the way to the right, value of 100 is essentially all objects stuck to the table. A good value to start with is 25. [

READ] This document.

[QUIT] Exit the app or start a new game.

### Try MIT App Inventor Yourself

You can started learning about using the App Inventor system HERE, and get your own free development site. Everything is online. But you can save your program files (with an “.ala” extension) to your computer or to the App Inventor Gallery to share your (brilliant?) code ideas with others. Additionally (this is the really good part) you can have your app code compiled to “standard” Android app files (.apk) that will work on pretty much any Android device. Your apps are easiest to share if you further apply to have them listed on Google Play. Here’s a YouTube video that outlines the steps.

https://www.youtube.com/watch?v=Y6noxzxsoLs.

**ROCKET 1**

I haven’t put this on Google Play because it’s a subset of Rocket Rangler. However it’s “.ala” form has been posted in the App Inventor gallery along with the seven program files for my Google Play posted app listed above. Once you sign up to use App Inventor, to retrieve the files navigate to the Gallery, then do a search for “dantastic.”

I developed a very basic version of Rocket Rangler called ROCKET 1.

It lets you control a rocket (no satellite) with a joystick, but doesn’t have all the bells and whistles. Because I want to share the basic program for you to experiment with, not only is the app itself available, but I am also publishing the MIT app inventor BLOCKS code.

**THE SCIENCE** ** Newton’s Laws of motion ** (1) Every object moves in a straight line unless acted upon by a force (like gravity, friction or a rocket engine). In this simulation the rocket’s and satellite’s paths are curved due the gravitational force acting on them.

(2) The acceleration (change of speed over time) of an object is directly proportional to the net force exerted and inversely proportional to the object’s mass. (In our case we are dealing with the force of gravity which decreases with the body’s distance from Earth added to the momentary force provided by firing the rocket’s engine.) Mathematically F = ma, force = mass times acceleration.

(3) For every action, there is an equal and opposite reaction. (The rocket’s jets are the “action.”)

**Newton’s law of universal gravitation**

A body attracts every other body in the universe using a force that is directly proportional to the product of their masses and inversely proportional to the square of the distance between their centers (of mass). As you double the distance between two bodies, the attraction between falls to one quarter of its previous value.

Mathematically the law is expressed, F = -GmM/r^{2}. F, the force, is expressed in Newtons, masses m (rocket/satellite) and M (Earth) in kilograms and r, the distance between centers of mass) in meters. G the universal gravitational constant, is 6.67×10^{-11} N m^{2} kg^{2}.

I think of G as a “fudge factor” relating mass and distance to give force in newtons. It would be numerically different if we used the English system of units, relating feet and slugs (the English unit of mass) to pounds, the unit of force.

How this relates to Rocket 1 and Rocket Rangler …

**THE MATH** I’ve chosen to use an approximation method (Euler’s Method) that requires only repeated multiplication and to track the trajectory of the body. You start with the body’s initial location, velocity and the force acting at that point. Use that information to calculate the location, velocity and force for the next point a short distance away after a short time interval. Use that to calculate the third point, and on, and on.

Mathematically the basic equations for the X (horizontal) direction are: If F = ma (Newton’s second law), then a = F/m. And F =-GmM/r^{2} (Newton’s law of universal gravitation) The minus sign tells us that the force is attractive. G is the universal gravitational constant, m is the mass of the rocket, M is the mass of the Earth and r is the distance between the centers of mass of the Earth and the rocket. Then, dividing both sides by m, the mass of the rocket or satellite, gives … The acceleration on an object due to gravity is a = -GM/r^{2}

At every point along the way we need to re-evaluate a, the acceleration, because the distance between the Earth and the rocket and satellite are constantly changing position. There are really only three steps repeated over and over again for the x and y directions.

← 1. a = -GM/r^{2} (where, by the pythagorean theorem, r^{2} = x^{2} + y^{2}) ↓

→ 2. new velocity = old velocity + acceleration x time ↓

→ 3. New position = old position + velocity x time The computer can loop through this simple procedure to plot out the body’s path through space. Euler’s method far from perfect. It depends upon the assumption that the time between one calculation and the next is so small that there isn’t much change. It breaks down when the rocket or satellite is close to the Earth where the gravitational force changes a lot from point to point. This can be fixed somewhat by making the time interval between point calculations smaller, making the distance between points smaller, requiring more calculations by the computer to plot the orbit. Here’s a program (not sure which language) that shows the steps…

FUTURE PLANS **NOT INCLUDED IN THE SIMULATION (THIS TIME)**

Fuel use – As a rocket expends fuel it loses mass. This can change the gravitational force acting on it.

Atmospheric friction – This force opposes the motion of the body causing it to eventually spiral into the Earth. It depends upon the density of the air and the body’s speed.

The satellite – Picking up the satellite increases the mass of the rocket.

Real astronomical units – Units are now in pixels, pixels/second, etc. Instead of including scaling factors that will display realistic astronomical distances, I’ve been lazy.

**Back to Physics … Questions about gravitation and orbital motion that you can investigate with this app …**

1. How does the period (time for one revolution) vary with distance from the Earth?

2. Kepler’s 3rd law: “the ratio of the squares of the periods of any two bodies about the Earth is equal to the ratio of the cubes of their average distances from the Earth.” Can you perform measurements to see if the simulation supports these laws?

3. If the rocket is in a circular orbit its speed is constant. Is it accelerating? Why?

4. If the rocket is in an elliptical orbit how does its speed change relative to its distance from the Earth? Can you think of a reason why?

5. Is there some speed that the rocket seems to keep going and going rather than being attracted back to Earth? Why or why not?

6. What is your best strategy for setting up a close orbit around the sun?

If you have comments you can send them to me through the contact form on this site or by email to, dan@dantastic.us.