Mobile application development
Mobile application development
Android Basics
- Android is sw stack based on a custom Linux OS.
Architecture
- Application layer
o Core (native) applications like Email client, SMS program, calendar
o Applications are written in Java or kotlin
o Each application lives in its own security sandbox
- Application API Framework
o Underlying all applications is a set of services and systems
▪ View system that can be used to build an application
▪ Content providers that enable data access
▪ Resource Manager
▪ Notification Manager
▪ Activity Manager
- Libraries
o c/C++ libraries used by various components
- Android Runtime
o Every android application runs in its own process, with its own instance of the Dalvik VM
- Core Libraries
o Basically inherited from java core libraries
- Linux Kernel
o Android relies on Linux version 2.6.x/3.0.x for core system services.
o Abstraction layer between the hardware and the rest of the software stack
o Manages many services like security, memory management, process management,
networking etc.
- Activities
o It is the entry point for interactivity with the user, it represents a single screen with user
interface
o You can have many such activities, and if app allows, other
apps can start these activities.
o The main activity is the one started first.
o Lifecycle.
▪ onCreate() => the activity is created
▪ onStart() => the activity is started
▪ onResume() => the activity is resumed after sitting in
the background
▪ onPause() => the activity is about to go into the
background
▪ onDestroy() => the activity is destroyed and thrown
out of memory.
▪ All android components have a lifecycle.
o Visability
▪ Foreground => the one shown to the user
▪ Background => mutliple ones hidded form the user.
o Fragments are used for a more dynamic and flexible UI design => divide the UI into
descrete chunks
▪ Combine multiple fragments to make an activity, can reuse frament in multiple
activites.
▪ Fragment lifecycle is affected by the host activity.
o Can activate activity using intents
- Services
o Performs actions in the background for some period of time, regardless of what user it
doing in the foreground.
▪ E.g. music player service like spotify.
o Do not implement a user interface.
o It is not by default a separate thread or process.
o 3 types
▪ Foreground => noticeable by user (music player). Requires showing a
notification.
▪ Background => not noticeable by user. Can be a security issue as the user cannot
control what is running in the background.
▪ Bound => offers programmatic client-server access. App binds to a service to get
X and then unbinds.
- Content Provider
o Component to receive events across and within
the app. Receive the events using intents.
o Using publisher-subscriber model
▪ Broadcast receiver subscribes to an
event, this is triggered by an intent.
▪ Related to event-driven programming.
o Example of events can be: battery charging, sms
is received, low battery status etc.
- Broadcast Receiver
o Data manager for the app.
o Apps can easily store/access/share data.
o High-level API to access data so that other
apps and services can query/interact with it.
o Abstract away the storing mechanism.
o Most often based on SQLite
o Can listen for intent-filters.
Intents
- Android Intent is the message that is passed between components such as activities, content
providers, broadcast receivers, services etc.
- It is generally used with startActivity() method to invoke activity, broadcast receivers etc.
- The dictionary meaning of intent is intention or purpose. So, it can be described as the intention
to do action.
- The LabeledIntent is the subclass of android.content.Intent class.
- Android intents are mainly used to:
o Start the service
o Launch an activity
o Display a web page
o Display a list of contacts
o Broadcast a message
o Dial a phone call etc.
- Implicit Intent doesn't specifiy the component. In such case, intent provides information of
available components provided by the system that is to be invoked.
o For example, you may write the following code to view the webpage.
▪ 1. Intent intent=new Intent(Intent.ACTION_VIEW);
▪ 2. intent.setData(Uri.parse("http://www.javatpoint.com"));
▪ 3. startActivity(intent);
- Explicit Intent specifies the component. In such case, intent provides the external class to be
invoked.
o Intent i = new Intent(getApplicationContext(), ActivityTwo.class);
o startActivity(i);
Manifest
User Interface
Broadcast receivers
- Broadcast Receivers simply respond to broadcast messages from other applications or from the
system itself. These messages are sometime called events or intents. For example, applications
can also initiate broadcasts to let other applications know that some data has been downloaded
to the device and is available for them to use, so this is broadcast receiver who will intercept this
communication and will initiate appropriate action.
- A broadcast receiver is implemented as a subclass of BroadcastReceiver class and overriding the
onReceive() method where each message is received as a Intent object parameter.
- An application listens for specific broadcast intents by registering a broadcast receiver in
AndroidManifest.xml file. Consider we are going to register MyReceiver for system generated
event ACTION_BOOT_COMPLETED which is fired by the system once the Android system has
completed the boot process.
- An Android service is a component that is designed to do some work without a user interface. A
service might download a file, play music, or apply a filter to an image. Services can also be used
for interprocess communication (IPC) between Android applications. Services in Android are a
special component that facilitates an application to run in the background in order to perform
long-running operation tasks. The prime aim of a service is to ensure that the application remains
active in the background so that the user can operate multiple applications at the same time.
Bind service
- A bound service is an implementation of the Service class that allows other applications to bind
to it and interact with it. To provide binding for a service, you must implement the onBind()
callback method. This method returns an IBinder object that defines the programming interface
that clients can use to interact with the service.
- Binding to a started service
o As discussed in the Services document, you can create a service that is both started and
bound. That is, you can start a service by calling startService(), which allows the service
to run indefinitely, and you can also allow a client to bind to the service by calling
bindService(). If you do allow your service to be started and bound, then when the
service has been started, the system does not destroy the service when all clients
unbind. Instead, you must explicitly stop the service by calling stopSelf() or stopService().
o Although you usually implement either onBind() or onStartCommand(), it's sometimes
necessary to implement both. For example, a music player might find it useful to allow its
service to run indefinitely and also provide binding. This way, an activity can start the
service to play some music and the music continues to play even if the user leaves the
application. Then, when the user returns to the application, the activity can bind to the
service to regain control of playback.
- Represent data about an application environment, context is the base class for activities,
services…
- It allows access to application-specific res and classes.
- It is the activity context meaning each and every screen got an activity. For example,
EnquiryActivity refers to EnquiryActivity only and AddActivity refers to AddActivity only. It is tied
to the life cycle of activity. It is used for the current context. The method of invoking the Activity
Context is getContext().
iOS Basics
- The architecture can be view as a set of
layers
Styles of programming
- Productive style
o Organization and manipulation of
detailed information
o Settings in apple
- Utility style
o Perform a specific task that requires
relatively little user input
o Interface should be visually appearling an uncluttered to make it easier to spot the
needed information quickly
▪ Weather app
- Immersive Application
o Full screen, visually rich environment that focused on the content and the users
experience with that content.
o Commonly used for fames and multimedia centric applications
Languages
- Objective C
o Object oriented language that adds smallTalk-style messaging to the C programming
language
o Almost everything is done at runtime; dynamic binding, dynamic typing and dynamic
linking.
o Swift was designed to interoperate with objective C.
- Swift
o Protocol oriented programming
o An extensibility system that can be applied to types, structs and classes
Design Patterns
- MVC => design pattern that govern the overall structure of you app
o Allows reusability and flexibility to you application
o Model is not aware of controller and view. Manipulate and process
data/algorithms/networking
o View is not aware of controller and model. Display/event capture/visual interaction
o Controller knows about view and model. Coordinate/delegate.
- Singletons => only one instance of the singleton class can be created or is alive at any one time
o Return the same instance no matter how many times an application request it.
- Delegation => one object delegate control to another object to act on its behalf. Transfer
information and data from one object to another.
o Main value is that it allows you to easily customize the behavior of several objects in one
central object.
- Key-value observing => enables an object to be notified directly when a property of another
object changes
- Target Action => translates user interactions with buttons and controls into code that you app can
execute.
- Sandboxing => protect the system and other apps
- Not Running: the app is considered to be in a Not Running state when it is not yet launched or
terminated by the system or user
- Inactive: running in the foreground but is currently not receiving events
- Active: running in the foreground but is receiving events
- Background: Background and executing code
o Before being suspended
o Background directly
- Suspended: Background and not executing code
Questions
1. Elaborate more on the usage of the app delegate and application object and their interactions?
a. Usage of the app delegation: the app delegate receives events from other object, other
object act on behalf of or in coordination with the app delegate. So, e.g. a window object
can send a windowShouldClose message to the app delegate and the app delegate can
respond with either yes or no. Messages the app delegate receives can either be an
event the delegating event is about to handle or has just handled. The response of the
app delegate can either effect how an event is handled, or it can update the appearance
or state of itself or other objects in the application.
b. Usage of the application object: the application object is created in the main function on
the launch of the application. The application object does the overall management of
running the application and is responsible for the initial routing of user events.
c. Their interactions: the application object can receive notifications when some external
event happens that affect the application. The application object then delegate to the
app delegate to get help in managing these events. The application object can also get
managing help from the app delegate when there are events related to the lifecycle of
the application. The app delegate sends a response, and the application object might act
upon this response.
Golden Rules
- When making a new app
o Who is the audience
o What is the purpose if the app
o What problem your app is trying to solve
o What content your app incorporate
o After you have a concept, design a good user interface
Rules
1. Decide what to build and figure out who your users are.
2. Visit app store and do some recon to figure out what have already been done and what the
current apps are missing.
a. Innovation through copying: good artis copy, great artist steal.
3. Explore possible solutions. Find minimal set of features that user need.
a. Better a good app for small users than a poor app for big number of users.
4. Sketch
a. Quality through quantity: more time you put here fixing things, the less cost you have
down the road to fix the same thing later. Cost increase to fix problem the longer you get
in the progress of the app.
5. Build a prototype.
a. Fail early to succeed sooner
6. Iterate => sometimes you need to go back and do it all again
a. Nothing is precious, you can throw anything away.
7. Begin coding => fist the interface and then the backend.
a. Top down approach
8. Beta test you app => get people to test.
9. Release, bug fix => talk to users and get feedback
a. Upgrade you app
App Monetization
- Converting app users into revenue
o Revenue requires happy users
SwiftUI
- One problem with swift is that you needed to go back to Obj-C to create a link between Swift
code and UI => that is when we see the shift to swiftUI
- Written with declarative swift syntax that’s easy to read, natural to write and works seamlessly
with Xcode design tools like the new canvas.
o Can see changes on emulator in real time
- Drawbacks
o Latest OS versions required
o Limited documentation and resources.
o Change of mindset => different approach to what the developers might be used to.
Everything is declarative and there are now bindings to objects, with a new framwork
called combine.
Marketing strategies
User Interface
Neutral user interface (NUI)
Mobile first
Context-aware app
- Capabilities
o Navigate the space around you
o Argument you immediate surroundings
o Interact with nearby objects, locations or people
- Context-aware app Ingredients
Sensors
- If app uses a specific sensor, how can we ensure this sensor exist on target device?
o Detect device sensors at runtime, enable/disable app features as appropriate.
▪ sensorManager.getDefaultSnsor(Sensor.TYPE_PRESSURE) != null
o Use Google Play filters so only devices possessing required sensor can download app.
▪ Can use <uses-feature> element in Android Manifest to filter your app from
devices without required sensors
RapidRide
Yoan HOUNGNIBO, Mayank
NARANG, Godwill ONCHE,
Sai, Logesh Dhanraj
BUSINESS MODEL
Name and slogan: Market phase and pricing model: Target users:
Your ride on demand, any time, anywhere. We earn a percentage during the wallet Everyone
recharge as well as taxi ride
FEATURES OF OUR APP
GPS-BASED REGIONAL PREDEFINED PAYMENT PRICE A BIT HIGHER EMBEDDED INFORMATION WALLET CHARGED
INFORMATION: INFO INFORMATION DURING THE RUSH ABOUT THE CAR BRAND DURING APP’S
ABOUT SCHEDULE ETC DEPENDING ON TRAVEL HOURS OF THE DRIVER DOWNLOADING, LATER
DISTANCE USE FOR PAYMENT
Rider Driver
App
Payment
Taxi
information
THE UI DESIGN
MobServe
2022
1. Android and iOS Application (1.5 point /Question)
a) What are the main Mobile app usage patterns when compared to a desktop application?
Mobile app usage patterns significantly differ from desktop applications primarily due to the context of use involving time and place. Mobile
apps are designed for anywhere and anytime use, often during periods of waiting, shopping, or during miscellaneous downtime. This results in
a usage pattern characterized by partial attention or short bursts of interaction, unlike desktop applications that might command full attention in
more static environments.
b) What are the main components of an Android application and an iOS application?
The main components of an Android application include Activities, Services, Content Providers, and Broadcast Receivers. For iOS applications,
the core components involve the use of View Controllers for managing user interface, Views for the interface elements, and Model objects for
the data.
c) Draw the lifecycle transitions of an Android and an iOS App?
The lifecycle of an Android app involves states such as Created, Started, Resumed, Paused, Stopped, and Destroyed, with transitions
triggered by user actions or system events. An iOS app's lifecycle includes states such as Not Running, Inactive, Active, Background, and
Suspended, with specific methods to manage transitions between these states, such as applicationDidBecomeActive ,
applicationWillResignActive , etc.
d) Describe different communication mechanisms in an Android and an iOS App?
Android apps can communicate through Intents, Broadcast Receivers, Content Providers, and Services. iOS apps use mechanisms such as
Delegation, Notifications, Segues for storyboard-based navigation, and Target-Action for UI controls.
2. Monetization (1 point /Question)
a) Explain App Store marketing model, its business model, and highlights its key advantages and drawbacks?
The App Store marketing model revolves around providing a platform for developers to sell or distribute their apps to consumers. Its business
model primarily includes charging developers a fee for app sales (a percentage of the price) and offering various tiers of in-app purchases and
subscriptions. Key advantages include a vast audience reach, security, and streamlined payment processes. However, drawbacks involve strict
app review policies, the challenge of app discoverability among millions of apps, and the commission fee on sales and subscriptions.
b)Provide a comparison table of 4 main App monetization strategies in view of different market phases (land grab, war, peace, differentiator)?
Give 1 or 2 example App for each.
Decision drivers between choosing SwiftUI or Storyboard include project requirements, target iOS version, team's familiarity with Swift and
declarative programming, and the complexity of the UI. SwiftUI is generally favored for its modern, code-centric approach that facilitates dynamic UI
creation and easier maintenance, especially for projects targeting iOS 13 and later. Storyboard is more suitable for projects that require broad
compatibility with older iOS versions or for developers who prefer a more visual approach to UI design.
2020
1. Based on the FlickrMap lab you built during the course, explain what is Objective-C and point out its relationship with Swift?
The document provides examples of implementing features in both Objective-C and Swift, indicating that Objective-C is a programming
language used for developing iOS apps before Swift. Swift is a more modern language introduced by Apple to simplify iOS and macOS app
development. The lab instructions demonstrate how both languages can be used for similar tasks, highlighting Swift's role as a successor to
Objective-C with improved syntax and features for iOS app development.
2. Android and iOS Application life cycle
a. Draw a table and compare the Android and iOS app development lifecycle methods
b. Explain how the Android life cycle changes when receiving a
i. Phone call
ii. Notification
iii. Changing the orientation
iv. Loss of connectivity during video streaming
a) To compare the Android and iOS app development lifecycle methods, we would typically create a table that outlines the key lifecycle
methods for both platforms. Since the documents provided do not directly contain a comparative table, I will outline a general comparison
based on common knowledge:
i. Phone Call: The current activity is paused ( onPause() ) when a phone call is received and resumes ( onResume() ) after the call ends.
ii. Notification: Receiving a notification doesn't necessarily change the lifecycle unless the user interacts with the notification, potentially pausing
the app if they switch to view the notification.
iii. Changing the Orientation: Causes the activity to be destroyed ( onDestroy() ) and recreated ( onCreate() ), going through the entire lifecycle
unless specific configurations are set in the manifest to handle orientation changes.
iv. Loss of Connectivity during Video Streaming: The app's lifecycle isn't directly affected by connectivity changes; however, the app needs to
handle these changes to manage streaming resources, potentially pausing or buffering the stream based on connectivity status.
These scenarios highlight the importance of managing the app's lifecycle to ensure a smooth user experience across different usage contexts.
a. Handler allows you to send and process Message and Runnable objects associated with a thread's MessageQueue. AsyncTask is
designed for short operations and performs background operations and publishes results on the UI thread without needing to manipulate
threads. Thread is a basic unit of execution in Android for separate operations but requires manual handling of thread management and
communication with the UI thread.
b. Improving Performance:
i. Heavy Computing: Utilize native libraries (NDK) for intensive operations and consider offloading processing to the cloud or a server where
feasible.
ii. Big File Downloads: Implement efficient streaming and caching mechanisms, use download managers for large downloads to handle
network variability and interruptions, and optimize file handling to minimize memory usage.
4. Android sensor framework
c. Name at least 7 sensors in an android device and identify whether they could be physical, virtual, or both.
d. There are four Java classes related to the use of sensors on the Android Platform. List them and explain the purpose of each.
e. How would you check for the presence of a Compass sensor?
c) Sensors in an Android Device:
1. Accelerometer (Physical)
2. Gyroscope (Physical)
3. Magnetometer (Physical) - often used for compass functionality
4. Proximity Sensor (Physical)
5. Light Sensor (Physical)
6. GPS (Physical) - for location tracking
7. Barometer (Physical)
These sensors can be categorized as physical, with some like the step counter acting as virtual, derived from physical sensors.
e) Checking for a Compass Sensor: Use the SensorManager to check for the presence of a Magnetometer sensor, as it is crucial for
compass functionality. This involves using SensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD) and verifying that the
returned object is not null.
Exam 2019 :
1. Smart App:
a. Definition: A smart app is a mobile application that leverages data, analytics, and various
technologies (e.g., machine learning, AI, IoT) to personalize the user experience and deliver
contextually relevant information and services.
b. Technology Enablers and Information:
• Data: User behavior, location, preferences, sensor data, etc.
• Technologies:
o Machine learning: Analyze data and make predictions/recommendations.
o Artificial intelligence: Interpret data and make decisions like humans.
o Internet of Things (IoT): Connect and collect data from physical devices.
o Cloud computing: Store and process large amounts of data.
c. Example:
• Smart navigation app: Uses GPS, traffic data, and user preferences to suggest
personalized routes, predict travel times, and provide real-time updates.
2. Android Components and Multithreading/Asynchronous Programming:
a. Main Components:
• Activities: Represent screens and handle user interaction. (Example: Login screen)
• Fragments: Reusable UI components within activities. (Example: Navigation menu)
• Services: Run in the background without a UI, performing tasks like music playback
or data fetching. (Example: Music streaming service)
• Content Providers: Share data between apps securely. (Example: Sharing contacts)
• Broadcast Receivers: Respond to system events like battery level changes.
(Example: Low battery notification)
b. Performance Improvement:
i. Heavy Computing:
• Use asynchronous tasks: Offload processing to background threads (e.g.,
AsyncTask, Kotlin coroutines).
• Utilize libraries like TensorFlow Lite for efficient on-device machine learning.
ii. Big File Downloads:
• Implement multi-threading for parallel downloads.
• Use libraries like Volley or Retrofit for efficient network calls.
• Download in chunks to avoid blocking the UI.
3. Monetization Strategies:
a. App Category and Market Phase:
Freemium,
Freemium
Subscription, Freemium,
Entertainment (Ads), Premium
In-app Subscription
Subscription
purchases
Freemium
Freemium,
(Ads),
Subscription, Freemium,
Education Subscription, Premium
In-app Subscription
In-app
purchases
purchases
Freemium,
Freemium Freemium,
Social In-app Freemium,
(Ads), In-app In-app
Network purchases, Subscription
purchases purchases
Subscription
Freemium,
Freemium Freemium,
In-app
Photography (Ads), In-app In-app Premium
purchases,
purchases purchases
Subscription
b. Device Type:
If the project requires custom model development and optimization for on-device execution,
TensorFlow Lite is the preferable choice. If the project benefits from simplified
implementation of common ML tasks and integration with other Firebase services, Firebase
ML Kit would be more suitable.
Use case example: Consider a photo management app that uses ML for organizing and
tagging images. TensorFlow Lite could be used for on-device image classification, providing
fast, offline sorting of photos into categories. Firebase ML Kit could be employed for
advanced features like cloud-based face recognition to tag friends in photos, benefiting from
the cloud’s processing power and broader knowledge base.
6- Based on the image provided and the task of designing a puzzle game app framework for
iOS, here are brief answers to your questions:
d. Monetization Strategies:
- In-App Purchases: Sell additional puzzles, themes, or special items.
- Subscription Model: Offer premium content on a monthly or yearly basis.
- Ads: Display ads, with the option for users to pay for an ad-free experience.
- Freemium Model: Provide the base game for free, with premium features available for
purchase.
- Merchandising: Sell related merchandise through the app.
- Educational Partnerships: Partner with educational institutions for custom content.
- **Main Classes:**
- **GameFramework:** The central class that manages game states and transitions.
- **Puzzle:** A class for individual puzzles, including properties like shapes, sounds, and
correct positions.
- **LevelManager:** Manages levels, including loading and unlocking new puzzles.
- **UserInterface:** Handles all UI elements, like buttons, score displays, and menus.
- **AssetManager:** Manages game assets, ensuring they are loaded and available when
needed.
- **ServiceManager:** Handles external services like in-app purchases, ads, and analytics.
- **UI Navigation:**
- **From Framework to Service:**
- The **GameFramework** detects a user action that requires a service (like making a
purchase).
- It calls the **ServiceManager** to handle the request.
- The **ServiceManager** interacts with the relevant service (like the App Store) and
returns the result.
- **From Service Back to Framework:**
- Once the service action is complete, the **ServiceManager** sends the result back to the
**GameFramework**.
- The **GameFramework** updates the game state based on the result (like unlocking a
new level after purchase).
This structure supports forward and backward navigation between the game's core logic and
the services used for monetization or other external interactions.
EXAM 2020
• Was the primary language for iOS development before Swift's introduction.
Swift:
• A modern, open-source programming language introduced by Apple in 2014.
• Offers features like type safety, automatic memory management, and powerful
closures.
Relationship:
• Swift and Objective-C can interoperate within the same project, allowing
gradual migration from Objective-C to Swift.
• Swift is now the recommended language for new iOS development due to its
advantages in readability, maintainability, and performance.
Coding,
Developmen resource
Coding, storyboard/Xcode Interface Builder
t creation,
testing
Compiling
Java/Kotlin
Building Compiling Swift code into App Bundle
code into
APK
Downloaded
Installation and installed Downloaded and installed on device
on device
onCreate() application:didFinishLaunchingWithOptio
Launching
method called ns
Methods
called based Methods called based on user interactions, system
Running
on user events
interactions
onPause(),
onStop(), applicationWillResignActive,
Background
onDestroy( applicationWillTerminate
)
System
terminates or
Termination System terminates or user swipes away
user swipes
away
Component Description
Handler Used for posting tasks to the main thread from background threads.
b. Performance Improvement:
i. Heavy Computing:
• Use AsyncTask or IntentService for background processing.
d. Java Classes:
1. SensorManager: Accesses device sensors and registers listeners.
2. Sensor: Represents a specific type of sensor and its capabilities.
3. SensorEvent: Contains data generated by a sensor.
4. SensorEventListener: Defines methods to receive sensor data updates.
e. Checking for Compass Sensor:
Java
SensorManager sensorManager = (SensorManager)
getSystemService(Context.SENSOR_SERVICE);
if (sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD) != null)
{
// Compass sensor available
} else {
// Compass sensor not available
}
5. UI Design:
a. Click Stream:
The sequence of user interactions with a website or app, recording elements clicked,
pages visited, etc.
b. UI Design Choices:
i. Gaming:
• Focus on clear and responsive controls: Users need to react quickly and
efficiently, so buttons and joysticks should be easy to find and use.
• Prioritize visual clarity: Minimize distractions and ensure key information is
readily visible, especially in fast-paced games.
• Consider adaptive UI elements: Adjust layout and controls based on screen
size and device orientation for optimal playing experience.
ii. Maps:
• Map orientation should be intuitive: North facing up or user direction being top
priority.
• Clear visual hierarchy for different map elements: Points of interest, routes,
and user location should be easily distinguishable.
• Dynamic zoom and filtering options: Allow users to explore at different levels
of detail and focus on specific information.
iii. Augmented Reality:
• Seamless integration of virtual elements with the real world: Ensure realistic
overlays and minimal visual clutter.
• Intuitive interaction mechanisms: Gestures, voice commands, or other
methods should be natural and responsive.
• Consideration of device limitations and user comfort: AR experiences should
be smooth and avoid causing motion sickness.
iv. Books, Magazines, News:
• Clean and uncluttered layout: Prioritize text readability and avoid distractions.
• Adjustable font sizes and themes: Cater to user preferences and accessibility
needs.
• Efficient navigation: Easy search, table of contents, and progress tracking.
c. SwiftUI vs. Storyboards:
SwiftUI:
• Modern, declarative UI framework built directly into Swift.
• Focuses on code-driven UI creation with live previews.
• Offers dynamic layouts and data-driven UI updates.
Storyboards:
• Visual interface builder for creating UIs using drag-and-drop elements.
• Easier to prototype and visualize layouts, especially for complex interfaces.
• Can be combined with code for dynamic behavior.
Main Differences:
• Development style: SwiftUI is code-centric, while Storyboards are visual.
• Flexibility: SwiftUI offers more dynamic control, while Storyboards are simpler
for static layouts.
• Learning curve: SwiftUI requires writing code, while Storyboards are more
beginner-friendly.
In-app purchases
IAPs (advanced
(car navigation Partnerships (car
driving features,
features, premium manufacturers,
CAR diagnostics),
upgrades), service providers),
(Onboard Subscriptions
Subscriptions Paid upgrades
Unit) (personalized
(connected car (hardware
plans, premium
services, data expansion)
content)
access)
Paid downloads,
IAPs (new levels, Ads (non-intrusive,
Freemium with
characters), Ads native), Sponsorships
IAPs (cosmetics,
Games (less frequent, (eSports, influencers), In-
consumables),
more targeted), game advertising
Ads (interstitials,
Subscriptions (branded items)
rewarded)
(season passes,
exclusive content)
Subscriptions
Freemium with (discounted bundles,
Paid
subscriptions personalized tiers),
Books, subscriptions, In-
(limited access, Partnerships (publishers,
Magazines, app purchases
premium content), news organizations),
News (individual issues,
Ads (targeted, Paid upgrades
articles)
non-intrusive) (audiobooks, offline
access)
Subscriptions
Freemium with
(discounted bundles,
Paid apps, subscriptions
lifetime access),
Freemium with (personalized
Partnerships
Education IAPs (premium learning plans,
(educational institutions,
courses, quizzes), Ads
learning platforms), Paid
certificates) (targeted,
certifications, In-app
educational)
tutoring
Subscriptions
Freemium with (discounted bundles,
subscriptions loyalty programs),
Paid apps,
(premium booking Partnerships (travel
Freemium with
Travel features, travel companies, booking
IAPs (offline
insurance), Ads platforms), Paid
maps, guides)
(targeted, upgrades (personalized
location-based) recommendations,
concierge services)
Remember, these are general guidelines, and the best monetization strategies will
depend on your specific app, target audience, and market trends.
• Parents who want to check their teen's driving habits (with consent) or
remotely unlock the car for them.
• People with limited mobility who can benefit from easier car access and
control.
Target Users:
• Tech-savvy individuals who appreciate convenience and remote control.
b. 4 Most Important App Features (Based on Your Use Case and Target Users):
EXAM 2022
2. Monetization
a) App Store Marketing Model:
- Business Model: App Stores facilitate the distribution and sale of apps, taking a
percentage of each sale or in-app purchase.
- Advantages: Provides a centralized marketplace for app discovery, easy payment
processing, and access to a large user base.
- Drawbacks: High competition, revenue share with the platform, limited control over pricing
and promotion.
3. UI Design
a) Important Considerations for Mobile App UI Design:
- Prioritize simplicity and ease of use.
- Optimize for touch interactions and small screens.
- Ensure consistency in design elements and navigation patterns.
- Design for performance and speed.
- Consider platform-specific guidelines and conventions.
Storyboard
SwiftUI
Development Faster due to declarative
Speed syntax Slower due to visual layout editing
Storyboard
SwiftUI
Code Reusability High Moderate
Moderate for experienced Lower for beginners, higher for
Learning Curve developers complex apps
Flexibility High Moderate
Preference for modern, Familiarity with traditional storyboard
Decision Drivers reactive design approach
Lab2 iOS: Baby Game
HelloWorld Questions
- One need to make sure that we design the layout for the same type of phone that we simulate
the program on. I was developing for Iphone 14 pro and ran the program on Iphone SE 3
generation. Here the text did not get centered as the screen I was designing the program on was
bigger than the one I ran the program on. Fixed this be changing the simulator phone.
Elaborate more on the usage of the app delegate and application object and their
interactions?
- The app delegate is the entry point of the application. The app delegate can receive events from
other objects, and other objects acts on behalf of or in coordination with the app delegate. The
app delegate decides what to do with events when it receives them, like if a window object
sends a windowShouldClose message, the app delegate can respond with either yes or no. The
response of the app delegate can either effect how an event is handled, or it can update the
appearance or state of itself or other objects in the application.
- The application object is created in the main function on the launch of the application. The
application object does the overall management of running the application and is responsible for
the initial routing of user events.
- The application object can receive notifications when some external event happens that affect
the application. The application object then delegate to the app delegate to get help in managing
these events. The application object can also get managing help from the app delegate when
there are events related to the lifecycle of the application. The app delegate sends a response,
and the application object might act upon this response.
Rebuild the project with SwiftU I and check how the view is constructed?
- What I first noticed when I tried to rebuild my project with SwiftUI was that it felt harder to learn
and jump into compared to Storyboard. Because with the storyboard it was so easy to just drag
and drop all the elements I wanted, and there was no need for a lot of code in the start. In swift
the different components had to be defined in the code, which was what I found difficult when I
started. But after playing around a little with SwiftUI there were some big advantages, like the
preview screen that made it easy to see and test the changes while developing, with storyboard I
had to run the app to test new functionality which too some time as the project needs to build
again for every time. Also, handling the flip of a button was easier to handle in SwiftUI as the
action to “flip” happened in the same button component. There was no need to make a new
function to handle this, this also made it easy to differentiate between the two buttons.
- I would call my app “happyShapes”, as this is simple and can explain a little of what the app
does. Also, it is easy to search for if one want to search for a game related to shapes.
- The monetization strategy I would go for is a freemium strategy within app purchase. As there
are other apps out there that also is for learning shapes that is free to download, I do not think
my app would be popular for choosing a subscription-based model as people can go elsewhere
and find a free app. In my app I could do some changes to make different levels, and different
types of levels. Not just drag and drop, also to make it harder when you come to a higher level.
This way users will feel they keep on getting a challenge and might continue playing. People will
most likely not keep on playing if they find the app not engaging enough. Also, as I mentioned, I
would want in app purchase. This way I can try to sell e.g., different layout of the game, maybe
different cheat methods, like in candy crush where one can by extra features to get help getting
through a level. Another feature I would like to add, is the limited number of lives, so if someone
cannot do a level, they lose a life. As they only have limited amounts of lives, they get the option
to buy more if they want to play after all the lives are gone. This is a commonly used technique in
many games, and I would also say that it is a clever technique as many people want to continue
playing even after losing all their lives.
IOS Lab4:
1. The pointer to the image is null. Could you identify the problem? Other checkpoints: Make
sure that you are delegating the MKMapViewDelegate
a. Had to make a variable as NSData and add the didSet property. The didSet observer
lets one execute code whenever a property has changed, so I added the loadImage
code inside this didSet.
2. Look in the code you wrote where we can find the size of the image and resize the
UIImageView, used to display it, in a way that the aspect of the image does not get changed.
o Tip: look at the “self.detail.image.contentMode”
a. This is done when making the image view in the assistant manager. Here we set
content mode to aspect fit.
3. Find on the help how to add an icon to the application and use the file icon.png for that
purpose.
a. Added an image in the asset, the image was already there from before.
4. Add also a UIActivityIndicatorView to inform the user that something is being processed.
a. Added an UIActivityIndicatorView inside the detail scene in the view. And then just
had to add a start animation when loading the photos and stop animation when the
photo was finally loaded.
5. Using a UIScrollView add multi-finger zoom to the image.
a. Added multi-finger zoom on the image by making a function updateZoomFor which
changes the size of the photo according to how much one zoom.
6. Using a UISwipeGestureRecognizer make the swipe gesture go from one picture to the next
a. Added the swipreGestureRecognizer for left and right swipe. Then we had to make a
function for changing the index of the photo according to how we swiped. One
problem was figuring out the max index if the images list. Tried using images.count,
but this one failed. After some testing we found out that we had to use
images.count-1 as the max index since I’m guessing the images.count will give back
the length of the list, and when using indexes the index is usually 1 less then the
length.
iOS lab3: Landmarks
For the section 6 the steps I followed to reach the final result was:
- I added all the views into the ContentView. The MapView and the CircleImage I first added into a
new Vstack embedded in the other Vstack.
- Now I tried to figure out how to align the imageCircle ontop if the Mapview in the Vstack. I found
that I could use overlay and then use offset to set the y position.
- It still did not look completely like the result as the Mapview was taking up a bigger part of the
screen. I therefor added a spacer and ended up with the current result.
Questions
1. When creating a custom SwiftUI view, where do you declare the view’s layout?
a. The layout is declared in the view’s initializer.
2. Which layout renders from the following code?
a. The third layout is the one rendered.
3. Which of these is the correct way to return three views from a custom view’s body property?
a. The first option is the correct one, with the Vstack.
4. Which is the correct way to use modifier methods to configure a view?
a. The third option is the correct one.
Johanne Dybevik, Marte Lien Johnsen October 2022
onCreate() is used in the beginning of the life cycle, to initialize and launch an
activity.
onStart() is used after onCreate, and is the function that makes the activity visible for
the user.
onResume() would be the following function to make the activity present in the
foreground lifetime.
onPause() is used if the activity should no longer be present in the foreground, and
should be followed by either onResume or onStop.
onStop() is the method used to make the activity no longer visible to the user, and
can be called after onStart and onPause.
onDestroy() is the final action which is called to finish and destroy the activity. It is
used after calling the onStop function.
2. In the ImplicitIntent example, could we use a different OnClick function per button?
It is possible to have several different OnClick functions for each button. This would
provide the same functionality, but with longer and repetitive code.
4. App chooser:
Made a “Share” button in our application which lets the user choose between
available applications.
Johanne Dybevik, Marte Lien Johnsen October 2022
5. Calendar functionality
Made an add calendar event button, which redirects to google calendar (google
calendar requires google account…)
Android Lab2: HelloPreferences
How is the Preferences class called?
a. The preference class is called using an intent, in the onOptionsItemSelected function.
You may be notified that user credentials are not actually reset and that the notification is not
received. How can this be done in the code?
b. To be able to make the notification I had to call the createNotificationChannel at the top
of the createNotification method. Also I only want the notification if the credentials are
reset, therefore I have to call the create notification method in the opendial function
under builder.setPostitivButton (where we agree to change the preferences.
There are some depricated functions. Some of them are due to the notion of Fragment.
d. The deprecated function is the addPreferencesFromResource function in the preference
class. So, to redesign using fragment one has to create a new fragment class, and move
the deprecated function into the fragment, and then invoke the fragment from a
preference activity class. What I can do with my app is to rename the preference class,
call it myPreferenceFragment and make it extend the PreferenceFragment class. Then i
make a new class, I call this myPreferenceActivity and make it extend PreferenceActivity.
In the myPreferenceActivity we need two classes: onBuildHeaders and isValidFragment.
The onBuildHeader loads the header of the preference from a xml file, this we will make
later. The header is a link to the fragment, myPreferenceFragment. The isValidFragment
is a method that was introduced after there was found a new vulnerability related to
fragment injection, the method checks if the fragment is of valid type for this activity.
Now we need to make the new xml file, I call this headerPreferences. Here we need
<preference-header
<header
Next, in the androidManufest, I have to change the activity I added earlier and change
the android:name=”.Preferences” to android:name=”.myPreferenceActivity”.
In the menu.xml file I need to add the ability to show the new preference. So I need to
add a new item with android:id=”@+id/preferences” and android:title=”Preferences”.
Last, I need to change the method invoking the preference class, the
onOptionsItemSelected method. Here I need to change from Preferences.class to
myPreferenceActivity.class.
Are the preferences saved in a persistent or volatile storage? In each case, explain where they are
actually stored.
f. The preferences are stored in an XML file, this is a persistent storage as it is not
dependent on a running instance. When restarting the app, the preferences will still be
the same, they can be reused. Volatile storage on the other hand needs power to
preserve the stored data. So, if we restart the app, the data will not be there when ran
again. Volatile memory is stored in RAM. Persistent storage can be located in the
internal memory, e.g. an internal SD-card.
Lab4 Android: Firebase
Part2:
1. This while loop is missing the last contact, could you explain why? After fixing this, if you press
again the button in your app, is something strange happening? If yes, explain how to fix it.
a. For me this while loop was missing the first contact. This was because the expression
“names.moveToNext()” will move to the next index in the list, and because it has a next
it will evaluate to true in the while loop. On the second loop this expression will evaluate
to false since we only have 2 elements and the second element do not have a next.
b. I fixed this by changing the conditional in the while loop to “! names.isAfterLast()”, so
this one checks if we are not after the last element in the list. After running this I ended
up in an infinity loop as I forgot to add, in the while loop, “names.moveToNext()” to
move to the next element in the list and then eventually move to after the last element.
Part 3
1. What are the advantages of Firebase and what is the business model behind it? (POV of the user
and the developer)
a. There are multiple advantages using firebase. Firebase can for instance help with
authentication, which often takes a long time to set up. Firebase makes this easy and
with minimal code which is good for a developer. Firebase also makes it possible to
authenticate using different means; email and password, Google, Facebook, phone
number etc., which is an advantage for the user as it can make it easier to both sign up
and sign into the application.
Firebase offer a real-time database, having a real-time database that constantly updates
the current data is essential for modern applications and makes a better user
experience. By using Firebase database, the application does not need to have its own
database, and this again makes development easier for the developer. This database is
best for data that does not require complex queries.
When using Firebase, it’s easy to integrate with google analytics, and this can give
developers an insight into how users interact with the application. From these
developers can add new features or remove redundant ones and making the user
experience better.
b. Firebase also have different pricing models depending on the process and long-term
goals of the application. One of them is the free plan which allow you to test out limited
basic feature before upgrading depending on what functionality the application needs.
Another price model is the pay-as-you-go, which allows you to pay what for what you
use. This can save cost by avoiding paying for more than is used.
2. Why Firebase is a relevant for mobile apps? Name 5 top benefits of using Firebase compared to
other approaches.
a. Firebase is relevant for mobile apps because it can enable users to synchronize data in
real-time, so the users do no have to refresh the screen. It can also help with managing
the app security and user authentication. Firebase is easily integrated with iOS and
Android which also is a benefit. The top 5 benefits is that firebase is easily integrated
with Google analytics, you have the real-time Database, it is easy to use authentication
and there are numerous authentication methods, firebase has Cashlytics that can send
you real-time alerts whenever a bug or crash occurs in the application, and firebase is
fast and safe to use. Firebase have a zero-configuration SSL that enhances the security of
content delivery.
3. Identify 5 applications that could benefit from Firebase in particular for multi-device users?
a. Applications that could benefit from Firebase is
i. BeReal
1. New social media application for android and iOS. You get a notification
once a day to take a photo of what you are doing in the moment. Takes
a photo with both front and back camera, and you share the photo with
your friends. Get updates from friends in the moment. Do not need
complex database queries and users expect fast updates.
ii. Vg
1. Norwegian application for android, iOS and web. Is a news application
were you also can get real-time updates of things happening throughout
the day, like traffic accidents etc.
iii. Zalando
1. Website used for shopping of clothes. You can sign in with you account,
can use different kinds of sign in methods and keeps track of shopping
carts and items you have liked.
iv. Posten
1. Norwegian application for tracking postal packages. Get real-time
updates about where the package is/where the package was last. Sends
notification when the package has arrived.
v. Toogoodtogo
1. Norwegian app for android and iOS, used by companies and consumers.
The app allows companies that sell food to post adds about goodibags
with leftovers that consumers can by for a cheaper price. This is to
prevent food waste.
References:
https://citrusbug.com/blog/advantages-of-firebase-mobile-app-development
https://blog.back4app.com/advantages-of-firebase/#Top_10_Advantages_of_Firebase
https://infotrust.com/articles/5-benefits-of-using-google-firebase/
https://www.linkedin.com/pulse/advantages-disadvantages-firebase-nav-adalyn/?trk=portfolio_article-
card_title
https://osdb.io/firebase-pros-and-cons-when-you-should-and-shouldnt-use-firebase-osdb/#ib-toc-
anchor-1