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

Chapter - 3

Uploaded by

maretuyared
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Chapter - 3

Uploaded by

maretuyared
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

2024

Mobile Application Development


Prepared By: Zakiyos Lencha (MSc.)
Chapter Three
3. Intents and Services
3.1. Introduction
After Completing this session(chapter), Students must Understand:

 Describe Intents and services


 Explain characteristics of mobile applications
 Discussed on successful mobile development

In our day-to-day life, we all come across a number of mobile applications that runs in the
background. Also, in many applications, certain tasks are being performed without using any
UI i.e. the task is being performed in the background. For example, the Music app of our
mobile device or any other Music application runs in the background and while using the
Music app, you can use any other application normally. So, this feature is implemented using
the Service or IntentService.

3.2. Intents and Services


We will look upon the differences between the Service and IntentService. But before moving
forward, we will have a quick revision about Service and IntentService. So, let’s get started.

Intent i = new Intent(this, YourIntentService.class);

startService(i); // For the service.

startActivity(i); // For the activity; ignore this for now.


Service

You can think Service as an Android component that is used to perform some long-running
operations in the background like that in the Music app, where we run the app in the background
and use other applications of the mobile parallelly. The best part is that you don’t need to
provide some UI for the operations to be performed in the background. By using Service, you
can perform some InterProcess Communication (IPC) also. So, with the help of Service, you
can perform a number of operations together because any application component can start a
Service and can run in background.

There are three ways of using Service:

1. Foreground: A foreground service is a Service that will let the user know about what is
happening in the background. For example, in the Music application, the user can see the
ongoing song on the device as a form of notification. So, here displaying notification is a must.
2. Background: Here, the user will never know about what is happening in the background of
the application. For example, while sending some images over Whatsapp, Whatsapp
compresses the image file to reduce the size. This task is done in background and the user have
no idea about what is going in the background. But for the API level 21 or higher, the Android
System imposes some restrictions while using the Background Service. So, take care of those
restrictions before using the Background Service.
3. Bound: The Bound Service is used when one or more than one application component binds
the Service by using the bindService() method. If the applications unbind the Service, then the
Service will be destroyed.

An Intent is a messaging object you can use to request an action from another app component.
Although intents facilitate communication between components in several ways, there are three
fundamental use cases:

There are two types of intents:

 Explicit intents specify which application will satisfy the intent, by supplying either the target
app’s package name or a fully-qualified component class name. You’ll typically use an explicit
intent to start a component in your own app, because you know the class name of the activity
or service you want to start. For example, you might start a new activity within your app in
response to a user action, or start a service to download a file in the background.
 Implicit intents do not name a specific component, but instead declare a general action to
perform, which allows a component from another app to handle it. For example, if you want to
show the user a location on a map, you can use an implicit intent to request that another capable
app show a specified location on a map.

Figure 1 shows how an intent is used when starting an activity. When the Intent object names
a specific activity component explicitly, the system immediately starts that component.

When you use an implicit intent, the Android system finds the appropriate component to start
by comparing the contents of the intent to the intent filters declared in the manifest file of other
apps on the device. If the intent matches an intent filter, the system starts that component and
delivers it the Intent object. If multiple intent filters are compatible, the system displays a dialog
so the user can pick which app to use.

An intent filter is an expression in an app’s manifest file that specifies the type of intents that
the component would like to receive. For instance, by declaring an intent filter for an activity,
you make it possible for other apps to directly start your activity with a certain kind of intent.
Likewise, if you do not declare any intent filters for an activity, then it can be started only with
an explicit intent.
[1] Activity A creates an Intent with an action description and passes it
to startActivity(). [2]The Android System searches all apps for an intent filter that matches
the intent. When a match is found, [3] the system starts the matching activity (Activity B) by
invoking its onCreate() method and passing it the Intent.

 Starting an activity

An Activity represents a single screen in an app. You can start a new instance of
an Activity by passing an Intent to startActivity(). The Intent describes the activity to start
and carries any necessary data.

If you want to receive a result from the activity when it finishes, call startActivityForResult().
Your activity receives the result as a separate Intent object in your
activity’s onActivityResult() callback. For more information, see the Activities guide.

For example, if you have content that you want the user to share with other people, create an
intent with the ACTION_SEND action and add extras that specify the content to share. When
you call startActivity() with that intent, the user can pick an app through which to share the
content.

Example

// Create the text message with a string.

Intent sendIntent = new Intent();

sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);

sendIntent.setType(“text/plain”);

// Try to invoke the intent.

try {

startActivity(sendIntent);
} catch (ActivityNotFoundException e) {

// Define what your app should do if no activity can handle the intent.

 Starting a service

A Service is a component that performs operations in the background without a user


interface. With Android 5.0 (API level 21) and later, you can start a service
with JobScheduler. For more information about JobScheduler.

For versions earlier than Android 5.0 (API level 21), you can start a service by using methods
of the Service class. You can start a service to perform a one-time operation (such as
downloading a file) by passing an Intent to startService(). The Intent describes the service to
start and carries any necessary data.

If the service is designed with a client-server interface, you can bind to the service from
another component by passing an Intent to bindService(). For more information, see
the Services guide.

 Delivering a broadcast

A broadcast is a message that any app can receive. The system delivers various broadcasts for
system events, such as when the system boots up or the device starts charging. You can
deliver a broadcast to other apps by passing
an Intent to sendBroadcast() or sendOrderedBroadcast().

3.3. Android Intents and Services


Use a PendingIntent instead of a nested intent. That way, when another app unparcels
the PendingIntent of its containing Intent, the other app can launch the PendingIntent using the
identity of your app. This configuration allows the other app to safely launch any component,
including a non-exported component, in your app.

Your app might launch intents to navigate between components inside of your app, or to
perform an action on behalf of another app. To improve platform security, Android 12 (API
level 31) and higher provide a debugging feature that warns you if your app performs an unsafe
launch of an intent. For example, your app might perform an unsafe launch of a nested intent,
which is an intent that is passed as an extra in another intent.

If your app performs both of the following actions, the system detects an unsafe intent launch,
and a StrictMode violation occurs:

1. Your app unparcels a nested intent from the extras of a delivered intent.
2. Your app immediately starts an app component using that nested intent, such as passing the
intent into startActivity(), startService(), or bindService().

The diagram in figure 2 shows how the system passes control from your (client) app to another
(service) app, and back to your app:

1. Your app creates an intent that invokes an activity in another app. Within that intent, you add
a PendingIntent object as an extra. This pending intent invokes a component in your app; this
component isn’t exported.
2. Upon receiving your app’s intent, the other app extracts the nested PendingIntent object.
3. The other app invokes the send() method on the PendingIntent object.
4. After passing control back to your app, the system invokes the pending intent using your app’s
context.
Fig 3.2. Diagram of inter-app communication when using a nested pending intent.

Difference between Service and IntentService

So, we have revised the concept of Service and IntentService. Till now, have you found any
difference between these two? If not, don’t worry, in this section, we will look upon some of
the differences between the Service and IntentService, so that it will be easier for you to find
which one to use in which condition. Let’s see the difference, point wise:

1. Usage: If you want some background task to be performed for a very long period of time,
then you should use the IntentService. But at the same time, you should take care that there is
no or very less communication with the main thread. If the communication is required then
you can use main thread handler or broadcast intents. You can use Service for the tasks that
don’t require any UI and also it is not a very long running task.
2. How to start?: To start a Service you need to call the onStartService() method while in
order to start a start IntentService you have to use Intent i.e. start the IntentService by
calling Context.startService(Intent).
3. Running Thread: Service always runs on the Main thread while the IntentService runs on a
separate Worker thread that is triggered from the Main thread.
4. Triggering Thread: Service can be triggered from any thread while the IntentService can be
triggered only from the Main thread i.e. firstly, the Intent is received on the Main thread and
after that, the Worker thread will be executed.
5. Main Thread blocking: If you are using Service then there are chances that your Main
thread will be blocked because Service runs on the Main thread. But, in case of IntentService,
there is no involvement of the Main thread. Here, the tasks are performed in the form of
Queue i.e. on the First Come First Serve basis.
6. Stop Service: If you are using Service, then you have to stop the Service after using it
otherwise the Service will be there for an infinite period of time i.e. until your phone is in
normal state. So, to stop a Service you have to use stopService() or stopSelf(). But in the
case of IntentService, there is no need of stopping the Service because the Service will be
automatically stopped once the work is done.
7. Interaction with the UI: If you are using IntentService, then you will find it difficult to
interact with the UI of the application. If you want to out some result of the IntentService in
your UI, then you have to take help of some Activity.
3.4. Characteristics of Mobile Applications
Mobile is a rapidly growing industry that attracts companies from many industries. Because of
the growing popularity of smartphones and tablets, mobile application development is
becoming more popular among business owners all over the world. A mobile application is a
software program that runs on a mobile device, such as a smartphone or tablet computer.
Despite being little software units with limited functionality, apps manage to provide high-
quality services and experiences to users. App Development Services can be a little expensive
for you without making any difference.

3.5. Successful Mobile Development

In today’s fast paced world, the mobile app market is expanding by leaps and bounds.
Consequently, mobile marketing strategies are becoming more competitive. To ensure the
visibility of apps in such a complex scenario, app makers need to be very particular about the
approach being followed for mobile app development (including game apps). To create a
successful mobile application, you need to follow a systematic approach to the mobile app
development lifecycle. We have summarized 10 steps to create a successful mobile application
to help you out in this process.

Finding the right development partner is the most crucial step in the process. Understanding
the technology stack, development challenges and other technical aspects can be difficult. It
can be troubling for entrepreneurs without tech backgrounds. So, find an app development
partner that takes care of your project professionally, without you having to look into
everything.

You can choose between:

• Freelancers: You can easily find freelancers who fit in your budget. However, freelancers
can forge their experience or portfolio, or they may have limited exposure to diverse industries.
This option can come with a lot of risks, but if you are on a budget, then it’s for you.

• In-House Development: You can hire an in-house development team for your project. This
option is a major investment, including recruitment costs, employee benefits, operational costs
for the team and more. However, you may have more control over in-house development teams
in terms of delivery and deadlines.

• App Development Agencies: With diverse portfolios and experienced engineers, app
development agencies are affordable, experienced, and professional. You don’t have to chase
them as you might have to with freelancers. Agencies have expert developers, designers,
project managers, creative artists and data scientists. However, not all app development
agencies are experienced in modern technologies.

• Silicon Giants: You can hand over your project to silicon giants like Oracle and IBM. But
this elite app development is rarely affordable for startups.
Step 1: A successful mobile app starts with an app idea

To create a successful mobile application, the first thing you need to keep in mind is:

 Identify a problem which can be resolved by your app


 Decide the features of your app

The app should provide customer with tangible benefits including reducing costs via
productivity enhancements, new revenue or improving the customer experience.

Step 2: Identification / Clarification

To create a successful mobile application, you need to identify or be clear about:


 Application target users – An app should always be developed keeping in mind the target
users of an application. Having a clear vision regarding the target group, enhance the success
ratio of an app.
 Mobile platforms and devices to be supported – Mobile platforms and devices should be
selected keeping in mind hardware performance, battery life, ruggedness and required
peripherals. Certain factors that needs to be considered while selecting mobile platforms and
devices includes coverage, device support, performance and other features.
 Revenue model – The app market is booming like never before. To ensure this resource
and generate revenue , app developer need to select appropriate approach in accordance with
the app. There are different models of generating revenue from mobile applications which
include paid applications, separate app and in-app freemiums, advertisements, subscription and
pay per download.These techniques can be employed to generate revenue. However, the
developer’s approach has to be in accordance with the application. It is highly essential for the
developer to attract the user and spend money on the various aspects of the application.

Designing your app is yet another significant factor responsible for success of an app in the
market. Remember, a good UX design and good UI-UX means good discoverability. An app
developer should concentrate on the UI design, multi-touch gestures for touch-enabled devices
and consider platform design standards as well. Today, emphasis is on the UI design of an app
as it plays a crucial role in the success of an app. A number of drag and drop app builders
are available in the market. Designing an app is becoming increasingly popular as it create an
instant impact on the mind of the user while ensuring usability of an app.

Step 4: Identify approach to develop the app – native, web or hybrid

Selecting the right approach for developing an app is highly important. Ideally, the backend
development of the app must be in accordance with the time and budget constraints of a client.
A number of app developers prefer to follow the agile methodology.

 Native: Native apps enables in delivering the best user experience but require significant time
and skill to be developed. These apps are basically platform specific and require expertise along
with knowledge. Native apps are costly as well as time taking to be developed and deliver the
highest user experience amongst all the approaches.
 Web: Web apps are quick and cheap ones to develop and can run on multiple platforms. These
are developed using HTML5, CSS and JavaScript code. These web apps are less powerful than
native apps.
 Hybrid: Hybrid approach is the latest approach to develop any app. This approach combines
prebuilt native containers with on-the-fly web coding in order to achieve the best of both
worlds. In this approach, the developer augments the web code with native language to create
unique features and access native APIs which are not yet available through JavaScript.

Step 5: Make an app prototype

Next stage, after identifying the approach is developing a prototype. It is actually the process
of taking your idea and turning it into an application with some basic functionality. A prototype
makes it quite easier to sell your idea to potential buyers who can now actually view the tangible
benefits instead of just visualizing or reading product description. It is quite helpful in attracting
investors and working with manufacturers and finding licensees. You can also share the
prototype app with testers for functional testing and get an idea of what needs to change to make
it a successful mobile application.

Even while working on a prototype, do ensure you take measures to secure your app against
unauthorized usage and access to data.

Step 6: Integrate an appropriate analytics tool


There is also a need to incorporate appropriate analytics which gives you a detailed picture of
how many visitors use your webs, how they arrived on your site and how can they keep coming
back.

Some of the mobile analytics tool which helps in this process:

 Google Analytics
 Firebase
 Mixpanel
 Preemptive

With data sciences, including predictive analytics coming up in mobile apps, it can make
your apps highly marketable.

Step 7: Identify your testers: Listen to them and incorporate relevant feedback

Beta testing is the first opportunity to get feedback from your target customers. It is especially
important as it enhances your visibility in the app store. It not only reduce product risk but get
you that initial push in the app store. To identify beta testers is another important task to have
a successful mobile app

Preparing for beta launch:

 Define target customer – It is highly important to identify and clearly define your target
audience. This will enable you identify the right testers during your beta tester recruiting.
Early market research helps in understanding market analysis which eases the process of beta
testing.
 Eliminate bugs – Before beta testing your app on different platforms you need to take into
account majority of the devices which eliminate device specific bugs. Alpha testing with a
small number of users enables to clear out maximum bugs. At the same time, device coverage
plan is significant for quality assurance of mobile app.
 Identify goals – Beta testing is the best opportunity to get real feedback from target customers.
It provides a great opportunity to further understand target market and their requirements.
Identifying goals for beta testing helps in focusing the efforts. These goals reduce your product
launch risk.

Step 8: Release/Deploy the app

Deploying an app requires plan, schedule and control of the movement of releases to test and
live environments.

Step 9: Capture the metrics

There has been significant rise in the mobile app users in the present decade. As a result, the
need to collect accurate metrics is highly important. As the number of consumers using mobile
applications steadily rises, the need to collect accurate metrics from them is increasingly
important. Unfortunately, many of the methods used to measure apps are taken from web
analytics.

Major input metrics which should be kept in mind:

 Funnel analysis signifies as to why users are failing to complete desired user actions including
in-app purchases or ad clicks
 Measuring social sharing signifies what aspects of your app are capturing the attention of your
users
 Correlating demographic data with user behavior
 Tracking time and location gives you insights into the contexts in which your app is used
 Finally, capturing the emergent behavior of your user base is critical

Step 10: Upgrade your app with improvements and new features
After capturing the metrics it becomes important to upgrade your app with improvements and
innovative features. A mobile app without innovative features loses its usability in long
run. Upgrading your app with innovative features enhances its visibility along with downloads
of an app. Also ensure you keep updating your app to meet new guidelines offered by the
various platforms, don’t let your apps stagnate.

These are some of the of steps which should be taken into account while developing an app.
Using these steps, you can develop an app ensuring success in long run. However, it is nearly
impossible to pen down the exact steps which are responsible for success of an app.

Bonus Step 11: Market your app right

While this doesn’t fall under the steps to “make” an app, it is definitely important to make your
app successful especially for small businesses. If you do not market your app well once it is
released, there is a high possibility of it being lost in the multitude of apps available on the
various android and apple app stores. So, make sure your market your app well. Social media
can be a useful tool here. This a bonus step to create a successful mobile application but it is
highly recommended that you use it for your own benefit.

You might also like