0% found this document useful (0 votes)
15 views

Mobile application development

Uploaded by

Robin Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Mobile application development

Uploaded by

Robin Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

MobServ Notes

Mobile Platform Landscape


- Three types of application types
o Native app
o Web app
o Hybrid app
▪ Mobile app
▪ Cross platform app
▪ Standalone runtime
• Removing the limitations of the browser
▪ Mobile cloud runtime (MBaaS
- Desicion Drivers
o Devices, platforms, and technologies are evolving fast.
o Web based applications will see better support in the near future
o Mobile will probably follow the path of the web

Mobile Apps Stores

- Platform vendors using apps as marketing angle


o More apps = more use case => network effect
o Apps are what is making phones so popular.

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.

Android Lifecycle and components

- 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);

- Talk with components in some or other apps.


- Explicit => specify which component of which app
- Implicit => just describe the type of action to perform
o Intent is sent around the system with hope that some other app will do something about
it.
o App might need to perform some action that is does not support and ask the OS if there
is any capable apps supporting it => example showing a location on a map, request
another capable app to show it.
- Intent filter
o Declare: my component can handle intent of “type”
o If two apps can handle, you get a popup to chose which to use. E.g. for sending an email
=> can use gmail or can use outlook.

Manifest

- Permissions protect many security related capabilities.


- Xml file containing all info. needed to run the app
- Set min and target API level
- List different components and intent filters
- Package name

User Interface

- Hierarchy of Views and ViewGroups


- A view is an object that knows how to draw itself on the screen and handle events.
- A view occupies rectangular areas on the screen
o Examples are EditText, ImageView, Button etc.
- Use XML files to make the UI.
- ViewGroup is a special view that can contain other views
o Example linearLayout, RelativeLayout
o Linare Layout: put every child, one after the other, in a line, either horizontally or
vertically.
o With a relative layout: you can give each child a LayoutParam that specifies exactly where
is should go, relative to the parent or relative to other children.

More info android

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.

Why we need service in Android?

- 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.

What is context in android?

- 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

iOS App States

- 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

- Want to build an app that users love.

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)

- Invisible UI helping human to continuously learn complex interactions.


- Intuitive UI usable without learning

Content First then navigation

- Lot of time spent for navigation to get the content


- The content itself could serve as the interface
- Content first then navigation instead of navigation first, then content

Mobile first

- Constraints make you more focus


o Screen size, performance, context
o Context => design for anywhere and anytime

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

BLUETOOTH TO GET OFFLINE LOAN CREDIT


NEARBY TAXIS, MESHED
TAXI’S NETWORK VIA
BLUETOOTH
UML DIAGRAM

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.

Strategy Land Grab War Peace Differentiator Examples


Freemium High user Strategy solidification, Stable user base, Unique features or Spotify (music
acquisition, lower increase in premium consistent premium services offered to streaming), Evernote
immediate revenue conversions upgrades stand out (note-taking)
Advertisements Building audience, Increased ad revenues High engagement, Premium ad-free YouTube (video
lower ad revenue as user base grows targeted ads options streaming), Instagram
(social media)
In-app Testing with early Expanding range of High user Exclusive items or Candy Crush
Purchases adopters purchases as user base engagement, steady features (gaming), Tinder
solidifies purchase flow (dating app)
Subscription Initial trials, building Growing subscriptions High retention, steady Niche content or Netflix (video
value proposition through enhanced revenue services streaming), The New
features York Times (news)

3. UI design (1 points /Question)


a) What are the most important consideration when designing a UI for a mobile App (considering mobile app usage patterns) ?
When designing a UI for a mobile app, important considerations include simplicity for ease of use, intuitive navigation to facilitate quick user
orientation, responsiveness to fit various screen sizes and orientations, finger-friendly tap targets to accommodate touch interactions, and
minimalistic design to reduce clutter and focus on essential features. These considerations are crucial due to the mobile app usage patterns of
brief interactions and the diverse environments in which the apps are used.
b) Sketch three UIs for a taxi application when (a) identifying the taxi, (b) riding towards the destination, and (c) destination is reached?
IMAGE TO BE PLACED HERE
c) Compare SwiftUI and Storyboard in a table? What are the decision drivers to chose Swift UI or Storyboard?

Feature SwiftUI Storyboard Decision Drivers


Design Declarative syntax for UI design Visual UI design with Choose SwiftUI for code-centric design, Storyboard for
Interface Builder visual layout design.
Learning Steeper for developers unfamiliar More intuitive for beginners SwiftUI may require learning new concepts, while
Curve with declarative frameworks with drag-and-drop Storyboard might be more accessible initially.
Interactivity Seamless integration with Swift for Requires outlets and actions SwiftUI for more dynamic and complex UIs, Storyboard
dynamic UIs for interactivity for simpler interactions.
Live Preview Provides a live preview of UI Limited live preview SwiftUI offers better real-time feedback during
components capabilities development.
Compatibility iOS 13 and later All iOS versions SwiftUI for newer projects targeting iOS 13+,
Storyboard for broader compatibility.
Feature SwiftUI Storyboard Decision Drivers
Maintenance Easier to maintain and iterate on Can become cumbersome SwiftUI is preferred for long-term maintainability and
code with complex UIs scalability.

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:

Lifecycle Event Android Method iOS Method


Initialization onCreate() viewDidLoad()
Start onStart() viewWillAppear()
Resume onResume() viewDidAppear()
Pause onPause() viewWillDisappear()
Stop onStop() viewDidDisappear()
Restart onRestart() N/A
Destruction onDestroy() deinit

b) The Android lifecycle changes in the following scenarios:

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.

3. . Android components and Multithreading/asynchronous programming


a. What is the difference between Handler, AsyncTask vs Thread in Android?
b. How can the performance of a mobile app be improved in the following two cases?
i. Heavy computing such as image/audio processing/recognition ii. Big file downloads such as movie/audio streaming
The documents you've provided do not directly address the differences between Handler, AsyncTask, and Thread in Android, nor do they cover
strategies for improving mobile app performance in the context of heavy computing or large file downloads. However, generally:

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.

d) Java Classes for Android Sensors:

1. SensorManager: Manages sensors, including listing and accessing them.


2. Sensor: Represents a specific sensor.
3. SensorEvent: Provides sensor data, including accuracy and timestamp.
4. SensorEventListener: Interface for receiving notifications from the SensorManager when sensor values change.

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:

Category Land Grab War Peace Differentiator


Freemium
Freemium, Freemium,
Game (Ads, In-app Premium
Subscription Subscription
purchases)

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:

Device Monetization Strategies

Handheld Device All above

TV Freemium (Ads), Subscription, In-app purchases

CAR Freemium (Ads), Subscription, In-app purchases

Wearable Device Freemium (Ads), In-app purchases

4. Android Sensor Framework:


a. Sensors:
1. Physical: Accelerometer, Gyroscope, Magnetometer, Proximity Sensor, Light Sensor,
Pressure Sensor, Temperature Sensor.
2. Virtual: GPS, Orientation Sensor, Rotation Vector Sensor, Game Rotation Vector
Sensor.
3. Both: Barometer (can be physical or virtual depending on the device).
b. Not all Android devices support every type of sensor. Developers should design apps to
gracefully degrade functionality or offer alternative features if a required sensor is not
available. Use Android’s package manager to check for sensor availability and conditionally
disable or enable features accordingly. Non-Hardware Homogeneity:
• Check sensor availability programmatically before using them.
• Provide alternative functionality or gracefully handle sensor absence.
• Avoid publishing apps relying on unsupported sensors for a wider audience.
c. Sensor Events and Listeners: Sensor events are used to report sensor measurements,
and listeners are interfaces that receive callbacks from the sensor system. Developers
implement listeners to respond to sensor events, such as changes in sensor data or
accuracy.

5. Machine Learning in Mobile Apps:


a. Use Cases:
1. Personalized Recommendations: Tailoring content or product suggestions based on
user behavior and preferences.
2. Image and Voice Recognition: For features like photo tagging, voice commands, and
authentication.
3. Predictive Text and Natural Language Processing: Enhancing user interaction with
chatbots and virtual assistants.
4. Anomaly Detection: Identifying unusual patterns or behaviors indicating fraud or
security breaches.

b. ML Model Deployment: Locally vs. Cloud-hosted


- Local Use Pros: Enhances privacy, supports offline access, offers real-time performance,
and reduces operational costs.
- Cloud-hosted Pros: Provides scalability, supports more complex models, simplifies updates
and maintenance, and offloads heavy computing from the device.

c. TensorFlowLite vs. Firebase ML Kit


TensorFlow Lite: Offers more flexibility and control over model training and deployment but it
requires deeper knowledge of machine learning and TensorFlow framework for custom
model development.
Firebase ML Kit: Provides a more straightforward, easy-to-use API for common ML tasks,
such as text recognition and face detection, without requiring in-depth ML expertise. It's
integrated with Firebase, offering a suite of cloud-based services. Less flexible for custom
model development compared to TensorFlow Lite and You're more dependent on the
provided APIs and pre-trained models.

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.

d. Combining TensorFlowLite and Firebase ML Kit


Yes, combining TensorFlow Lite and Firebase ML Kit in a single app is possible and can be
beneficial in certain scenarios.
Because we can use TensorFlow Lite for custom, optimized models specific to our
application's needs while leveraging Firebase ML Kit for its ready-to-use, pre-trained models
and easy integration with other Firebase services. It can be good for adaptive use cases.
Depending on the user's situation (e.g., internet connectivity, need for real-time processing),
the app can switch between local and cloud-based processing.

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:

a- Most Important Features of the App:


1. Intuitive Interface: Easy-to-use for the target age group, with simple drag-and-drop
mechanics.
2. Scalable Framework: Ability to add new puzzles and themes without changing the core
code.
3. Dynamic Difficulty Levels: Adjustable settings to increase the challenge as the user
progresses.
4. Engaging Feedback: Visual and auditory feedback for actions to keep users engaged.
5. Parental Controls: Features for parents to monitor progress and restrict certain content.
6. Multi-Language Support: To make the app accessible to a broader audience.

b. Six Games that Can Be Built with the Framework:


1. Shape Matching Game: Players match shapes into the correct slots.
2. Animal Sounds Puzzle: Match animals to their sounds.
3. Color Sorting Game: Drag objects into the area with the corresponding color.
4. Memory Matching Game: Flip cards to find pairs.
5. Alphabet Soup: Arrange letters to form words.
6. Number Cruncher: Combine numbers to reach a target sum.

c. Designing a Generic App Framework:


- Modular Design: Separate the core game mechanics from the content, so new games can
be created by just changing the assets and rules.
- Reusable Components: Develop components like timers, score trackers, and level
progressions that can be reused across different games.
- Data-Driven: Use external files (like JSON or XML) to define game levels, puzzles, and
assets, allowing for easy updates.
- Customization API: Provide an API for developers to customize game themes, sounds, and
difficulty levels.
- Performance Optimization: Ensure the framework is optimized for smooth performance
across different iOS devices.
- Documentation: Provide clear documentation for other developers to understand how to
use the framework to build new games.

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.

e. Sketching the Main Class Diagram and UI Navigation:


Creating a sketch of a class diagram and UI navigation would typically require a visual
representation, which isn't feasible in this text format. However, I can describe how it might
be structured:

- **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

1. Objective-C and Swift:


Objective-C:
• An object-oriented programming language originally developed for Apple
platforms.

• It combines C syntax with object-oriented concepts like classes, inheritance,


and protocols.

• Was the primary language for iOS development before Swift's introduction.

Swift:
• A modern, open-source programming language introduced by Apple in 2014.

• Designed to be safe, expressive, and efficient for developing iOS, macOS,


tvOS, watchOS, and other Apple platforms.

• 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.

2. Android and iOS App Life Cycle:


a. Comparison Table:
Stage Android iOS

Coding,
Developmen resource
Coding, storyboard/Xcode Interface Builder
t creation,
testing

Compiling
Java/Kotlin
Building Compiling Swift code into App Bundle
code into
APK

Distribution Play Store App Store

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

b. Android Life Cycle Changes:


i. Phone Call:
• onPause() called when call receives focus.
• onRestart() called when returning to app after call.
ii. Notification:
• onMessageReceived() (Firebase) or custom notification handling code is
triggered.
• onResume() called if app is in background and notification opens it.
iii. Orientation Change:
• onConfigurationChanged() called to adjust layout for new orientation.
iv. Loss of Connectivity:
• onDisconnected() (if using network libraries) or custom network listeners are
triggered.
• Video streaming might buffer or pause depending on implementation.

3. Android Components and Multithreading:


a. Handler, AsyncTask vs Thread:

Component Description

Handler Used for posting tasks to the main thread from background threads.

Background thread management with automatic UI updates on


AsyncTask
completion.

Thread Manual thread creation and management, requiring more control.

b. Performance Improvement:
i. Heavy Computing:
• Use AsyncTask or IntentService for background processing.

• Consider libraries like TensorFlow Lite for 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.

4. Android Sensor Framework:


c. Sensors:
1. Physical: Accelerometer, Gyroscope, Magnetometer, Proximity Sensor, Light
Sensor, Pressure Sensor, Temperature Sensor.

2. Virtual: GPS, Orientation Sensor, Rotation Vector Sensor, Game Rotation


Vector Sensor.
3. Both: Barometer (can be physical or virtual depending on the device).

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.

Choosing between them:


Consider your project's requirements, team's experience, and personal preference.
For dynamic, data-driven UIs, SwiftUI might be preferred. For simpler layouts and
rapid prototyping, Storyboards could be helpful.

6. App Monetization Strategies:


a. Comparison Table (By Device Type):

Growth Market Mature Market


App Category Early Market Phase
Phase Phase

Paid app IAPs (new content, Ads (native,


Handheld
downloads, consumables), Ads video),
Device
Freemium with in- (more targeted, Subscriptions
(Smartphone)
app purchases less intrusive), (discounted
(IAPs), Ads Subscriptions bundles), Paid
(banners, (personalized tiers) upgrades,
interstitials, Partnerships
rewarded),
Subscriptions
(freemium or
premium)

IAPs (premium Subscriptions


Freemium with IAPs, features, content), (discounted
Subscriptions, Ads Subscriptions bundles),
TV (ISP Box)
(targeted, non- (tiers, bundles), Sponsorships,
intrusive) Ads (less frequent, Partnerships, Paid
shorter) add-ons

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)

IAPs (new watch Paid upgrades


Freemium with IAPs
faces, workout (hardware,
(watch faces, fitness
Wearable programs), advanced
data insights),
Device Subscriptions sensors),
Subscriptions
(Watch) (personalized Partnerships
(premium fitness
coaching, health (fitness brands,
tracking, coaching)
monitoring) health insurers)

b. Comparison Table (By App Category):

App Early Market Growth Market


Mature Market Phase
Category Phase Phase

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

Freemium with Subscriptions


subscriptions (discounted bundles,
Paid apps,
(premium custom plans), In-app
Freemium with
features, team purchases (premium
Productivity IAPs (pro
collaboration), templates, integrations),
features, storage
Ads (less Partnerships
upgrades)
frequent, non- (productivity tools,
intrusive) businesses)

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)

Paid apps, Freemium with Subscriptions


Healthcare
Freemium with subscriptions (discounted bundles,
IAPs (premium (personalized family plans),
consultations, health plans, Partnerships (healthcare
health data monitoring), Ads providers, insurance
analysis) (targeted, health- companies), Paid
related) upgrades (advanced
diagnostics, wearable
integration)

Remember, these are general guidelines, and the best monetization strategies will
depend on your specific app, target audience, and market trends.

7. Automotive Monitoring App Design:


a. Use Case and Target Users:
Use Case: Remotely control and monitor your car using a smartphone or smartwatch,
especially useful for:
• Busy professionals who want to control car climate, lock/unlock remotely, or
pre-heat/cool it before use.

• 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.

• Busy professionals and parents who value time-saving solutions.

• People with specific needs due to mobility limitations.

b. 4 Most Important App Features (Based on Your Use Case and Target Users):

• Remote Control: Ability to remotely lock/unlock doors, adjust climate control


(AC, heating), turn on lights, and honk the horn.
• Car Status Monitoring: Real-time updates on battery level, fuel level, tire
pressure, and location tracking.
• Notifications and Alerts: Alerts for unusual activity (door left open, low battery,
sudden movement), maintenance reminders, and geofence notifications
(entering/leaving designated areas).
• Personalized Profiles and Access Control: Create different profiles for family
members with varying access levels and permissions.

c. App Conceptual Architecture and Communication Models:


• Components: Client (smartphone/watch app), Server (cloud-based backend),
Car (onboard unit).
• Communication: Secure network communication (e.g., HTTPS) between client
and server, server and car (can involve cellular, Wi-Fi, Bluetooth).
• Data Flow:
o User sends commands from client app.
o Client encrypts and sends data to server.
o Server authenticates user and validates request.
o Server sends commands to car via secure connection.
o Car executes commands, sends confirmation or error message back to
server.
o Server relays response to client, possibly with car status updates.
d. App UI and Click Stream (Smartphone + Watch):
• Smartphone App:
o Dashboard with car status (climate, battery, location) and controls (AC,
lock/unlock, lights).
o Maps integration for remote location check and navigation.
o Settings for user management, notifications, and car pairing.
• Watch App:
o Simplified controls (AC, lock/unlock) and status display (e.g.,
temperature).
o Voice commands for hands-free interaction.
o Preset options for quick actions (pre-heat, unlock for kids).
• Click Stream:
o User opens smartphone app.
o App fetches and displays car status.
o User taps AC button.
o App sends command to server.
o Server sends command to car.
o Car adjusts AC and sends confirmation.
o Server relays confirmation to app.
o App updates AC status on screen.
o Watch app simultaneously reflects updated status.
e. Smartphone-Watch Communication:
• Options: Bluetooth Low Energy (BLE) for low power, Wi-Fi direct for faster
data transfer.
• Server can act as intermediary, receiving updates from car and pushing them
to both devices.
• Watch app can also directly connect to car if feasible and secure.
f. Required Classes:
• Smartphone and Watch: User interface class, communication class, car data
management class, authentication class.
• Server: Car management class, user management class, communication
class, security class.
• Car (Onboard Unit): Command processing class, communication class, sensor
data management class.
g. UI Optimization for Multiple Screen Sizes:
• Responsive design principles: Use relative units, flexible layouts, and media
queries.
• Adaptive UI components: Design components that can adjust their size and
layout based on screen size.
• Test on different devices: Ensure functionality and usability across various
screen sizes and resolutions.

EXAM 2022

1. Android and iOS Application


a) **Mobile App Usage Patterns vs. Desktop Applications:**
- Mobile apps are optimized for smaller screens and touch interactions, whereas desktop
apps typically have more screen real estate and are navigated using a mouse and keyboard.
- Mobile apps prioritize simplicity, speed, and convenience, while desktop apps may offer
more complex features and functionality.
- Mobile apps often leverage device-specific features like GPS, camera, and sensors, while
desktop apps may rely more on desktop hardware and peripherals.

b) Main Components of Android and iOS Applications:**


- Android: Activities, Services, Broadcast Receivers, Content Providers, Fragments, Views,
Intents.
- iOS: View Controllers, Views, Models, Delegates, Storyboards (or SwiftUI for newer
apps), App Delegate.

c) Lifecycle Transitions of Android and iOS Apps:


- Android: onCreate(), onStart(), onResume(), onPause(), onStop(), onDestroy().
- iOS: applicationWillEnterForeground(), applicationDidBecomeActive(),
applicationWillResignActive(), applicationDidEnterBackground(), applicationWillTerminate().

d) Communication Mechanisms in Android and iOS Apps:


- Android: Intents for inter-component communication, Broadcast Receivers for system-
wide events, Content Providers for sharing data between apps, and Services for background
processing.
- iOS: Delegates and protocols, Notifications for inter-component communication, URL
schemes and deep linking for app-to-app communication, and Background modes for
background processing.

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.

b) Comparison Table of App Monetization Strategies:

Strategy Land Grab War Peace Differentiator


In-App Purchases Candy Crush Saga Clash of Clans Pokémon GO Tinder Gold
Subscriptions Netflix Spotify The New York Times Headspace
Ads Facebook Instagram Twitter TikTok
Freemium Dropbox Evernote LinkedIn Slack

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.

b) Sketches for a Taxi Application:


- Identifying the Taxi: Search bar with map showing nearby taxis.
- Riding Towards the Destination: Map view with route details and driver information.
- Destination Reached: Fare summary with payment options and rating system.

c) Comparison of SwiftUI and Storyboard:

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

Why is the text not centered? How this can be fixed?

- 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.

What is the iOS app states (lifecyle)?

- The app states in iOS are:


a. Not running: In this state the app is not running. So, either the program has not been
started or has been terminated.
b. Inactive: The app is running in the foreground but is not receiving any event. This can
e.g., happen if the phone receives a call.
c. Active: the app is running in the foreground and is receiving events.
d. Background: The app runs in the background and is executing code. An app can be
switched to background state if the user e.g., switches from one app to another. Then
the not currently used app is running in the background.
e. Suspended: The app is in the background, but code is not being executed.

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.

Baby Game Questions


Propose a relevant name and monetization strategy for this app.

- 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

MobServ Lab 1 - Android


1. When and for what purpose are the following methods called during the lifecycle of
an Activity?

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.

3. Use an example to illustrate the relationship between different application


components.

To illustrate the relationship between the different application components, we can


look into an example when a user wants to perform this action to edit the first
contact, considering the four main components Activities, Content Provider, Service
and Broadcast Receiver:

Generally when running an application, there are Services running in the


background. Start the program .. We obtain our view of the program from the XML
file, here we have all the buttons. Clicking the “Edit contact button” initiates an
Activity and creates an Action_edit Intent. To be able to edit the contact requires
information about the first contact , given by the Content Provider. This would
further initiate a new activity, the edit contact view. After editing, saving of the
information is done in the background by a Service component.

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.

Implement exit function for the button3 to exit the application.


c. Implemented the exit button in the onCreate method.

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

and in here we need to add android:fragment, which is the


myPreferenceFragment, can also add android:title and
android:summary.

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.

Give example of applications where such preferences are useful?


e. Preferences such as username and passwords are useful in all apps where we need to
store some information about the user, or where we need to authenticate the user. An
example is facebook, where each user has different kinds of data related to it.

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.

2. What is an adapter and how does it work?


a. The adapter is responsible for keeping track of all the data elements we have in our
listview. It is also responsible for making the view for the data elements. So, in the code I
can see that we call the row_contact View I made for each entry in the listview. The
adapter gets the data from the array of contacts and converts the items in the list into a
view we can use with the row_contact layout.

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

You might also like