📘 CodingMarble Learn

Mobile App Design: Mobile Terminals, App Architecture, Sensors, Storage and Networking, Security

A phone is a small computer with a touch screen, sensors, storage and radios for networks. A mobile app is usually built in three layers: the screen (UI), the logic (rules) and the data. Apps read sensors such as the accelerometer, GPS and camera. They keep data in local storage on the phone and talk to servers over the internet using requests and responses. Good apps work offline and sync later. For security the app asks for permission before using sensors or files, and it locks (encrypts) private data and sends it only over secure connections.

🎬 Step-by-step story

  1. A phone is a small computer: a screen, sensors, storage and a network radio. An app uses these parts.
  2. An app has three layers: the screen (UI) on top, the logic (the rules) in the middle and the data at the bottom.
  3. Sensors: tilt the phone. The accelerometer gives a number for the tilt and the red ball rolls that way.
  4. Storage and network: data is kept on the phone first and then goes over the internet to a server. With no internet the app still works from the phone's storage.
  5. Security: an app may use a sensor only after the user allows it, and private data goes out locked (encrypted).
  6. Free play: change the tilt, switch the internet on or off, and press the permission and lock options.

Tip: drag the 3D scene to turn it. Use two fingers to zoom.

🤔 Common doubts, cleared

Is a phone really a computer?

Yes. It has a processor, memory, storage, a screen for input and output, and also sensors and radios. See the labelled parts.

Why divide an app into layers?

Each layer does one job, so we can change the look without breaking the rules. Watch the three coloured layers.

How does the phone know it is tilted?

The accelerometer measures the push of gravity along x, y and z. Slide the tilt and watch the number and the ball.

What happens to my data when the internet is off?

It stays safe in the phone's storage and is sent later. The yellow packet stops and the line turns red when you switch the internet off.

Why does the app ask for permission?

Sensors and files are private. The user must be able to say no. Without permission the sensor reading is blocked.

What does locking (encryption) change?

The same data is sent as unreadable code, so a thief on the network cannot read it. Switch the lock on and read the status.

Mobile terminals: what is inside a phone?

A mobile terminal is a handheld computing device: a smartphone, a tablet or a smartwatch. Main parts:

Common systems are Android and iOS. Apps can be native (made for one system), web apps (run in a browser) or cross-platform (one code for both).

App architecture: UI, logic and data layers

Splitting an app into layers keeps it neat and easy to change.

A tap goes down the layers and the answer comes back up. Because each layer has its own job, you can change the look without breaking the rules. Good UI design for phones: big touch targets (at least 44 px), simple screens, one main action per screen, and responses within a second.

An app has a life cycle: it starts, goes to the background when the user switches apps, and can be closed by the system. Save the user's work when it goes to the background.

Sensors in apps

Sensors turn the real world into numbers.

Sensor readings are noisy, so apps smooth them (average a few readings) and read them only when needed to save battery.

Storage and networking

Local storage keeps data on the phone: small settings (key and value), files (photos), and a small database (for example SQLite) for lists. It is fast and works offline, but it is lost if the phone is lost, and other devices cannot see it.

Network storage (cloud) keeps data on a server. Many devices can share it, but it needs internet.

How an app talks to a server: the app sends a request (for example, 'give me the bus list') to an API address using HTTP or HTTPS, and the server sends back a response, often in JSON text.

Offline-first design: save to the phone first, then sync to the server when the internet comes back. Also mind mobile data cost: send small data and cache what does not change.

Security of mobile apps

A phone holds private things: photos, messages, location and money apps. Apps must protect them.

Users should install apps only from trusted stores and read what an app asks for.

Try it: design a small app on paper

Plan a steps-counter app. Draw one screen. Write what the UI, logic and data layers do. Which sensor does it use? Where do you store the steps, and which permission is needed?

In the 3D go to the last step. Switch the internet off and then on: what happens to the data path? Allow the permission and tilt the phone: when does the sensor reading appear?

Key formulas and definitions

Worked examples

1. A phone lies flat on a table. About what does the accelerometer z reading show?

About 9.8 m/s² (gravity), and almost 0 on x and y.

2. An app must download a 6 MB file on a 2 Mbps connection. How long does it take?

6 MB = 6 × 8 = 48 megabits. Time = 48 ÷ 2 = 24 seconds.

3. Which layer should hold the rule 'show a red alert if temperature > 40'? The UI, logic or data layer?

The logic layer holds the rule. The UI only shows the red alert.

4. Why should a torch app not ask for contacts permission?

It does not need contacts. Asking for more than needed is a privacy risk, and users will not trust it.

5. A to-do app saves tasks on the phone first and uploads when Wi-Fi is on. Name this design and one benefit.

Offline-first with sync. Benefit: the app works without internet and nothing is lost.

Common mistakes

Practice quiz

1. Which layer shows buttons and lists?
2. Which sensor tells how the phone is tilted or moved?
3. What does offline-first mean?
4. Encryption means:
5. Before using the camera, an app should:

Practice: answer these yourself

Type or choose your answer, then press Check. Use a hint if you are stuck; the full solution appears after you answer.

Frequently asked questions

How does a mobile app work?

It shows a screen (UI), applies rules (logic), and reads or saves data on the phone or on a server. It can also use sensors like the accelerometer.

What is the difference between local and cloud storage?

Local storage is on the phone, fast and works offline. Cloud storage is on a server, shared between devices, but needs internet.

Why do apps ask for permissions?

To protect privacy. The user decides whether the app may use the camera, location, contacts or other private things.

Where this is taught

China高三Electives (选修)

Learn first

Related lessons

All Computer Science lessons