Other Stuff

Published on February 19, 2022

Check if image is landscape

Set a link for an image in App Inventor

Note: currently you cannot close a screen in the companion, you will have to build the app to test it out.

Screen1

Screen2

Navigating with a simple compass app

I found this image from Wikipedia. Thank you Brosen and Taifun!

Two ways to check if a year is a leap year

Before we begin, you need to know the following.

  • 2024 is a leap year because 2024 is divisible by 4.

  • 2022 is not a leap year because 2022 is not divisible by 4.

  • 1900 is NOT a leap year because although it is divisible by 4, for years that end with 00, they must be divisible by 400 at the same time.

  • 2000 is a leap year because 2000 is divisible by 400.

Method #1 - Using the Clock component to determine date before March 1.

Method #2 - Determining by analyzing the year (divisible by 400? divisible by 4 and 100 but not divisible for 400? divisible by 4 and not 100?)

Get number of days a month has

Logic: for exmple, the month is 6 and the year is 2022. We will attempt to get the date before July 2022, which is June 31, 2022. However, it returns an instant, so we get the day number from the instant. December is special because the next month is in a different year, so we just provide 31.

Pythagoras With App Inventor

Suppose side AB is side a, side AC is side b and side BC is side c.

The pythagoras theorem states that:

a² + b² = c²

So deeper evaluating it, to get only c, you will have to apply square root to both sides of the equation.

c = √(a² + b²)

Applying this with App Inventor blocks, you only need

However, if you want to get side a, you need a different approach. Remember this equation?

a² + b² = c²

From the relationships between addition and subtraction, you can get:

c² - b² = a²

To get only a, you will have to apply square roots to both sides.

√(c² - b²) = a

Summing it up, you can see this.

Easy enough to calculate side B.

Two Minutes Timer with Clock component

Get list of days in a month/year and get weekday name from date

Thanks for METRIC RAT AI2 for providing part of their work.