0% found this document useful (0 votes)
46 views4 pages

Chapter 7

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)
46 views4 pages

Chapter 7

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/ 4

2024

Mobile Application Development


Prepared By: Zakiyos lencha(MSc.)
Chapter Seven
7. Location
7.1. Introduction
After completing this chapter, Students must able to:

 Describe mobility and location-based services

Location, location, location. The changing location of the user and the device used by the user
make mobile applications fundamentally different from their stationary counterparts. Yet, most
software developers, even those who have some experience with mobile applications, have
little experience and understanding in how location-based information is gathered and
distributed and how this information may be utilized by mobile applications. Although we will
not be able to cover all aspects of location-based information in mobile applications, we will
try to tackle the basic problems in this chapter.

If you have looked into developing mobile applications, you have certainly heard of “location-
based services.” The UTMS Forum defines location-based services as follows:

This definition is somewhat narrow as it limits location-based services to 3G services. There


are many location-based services that do not have any relationship with 3G services. So,
location-based services are those things that provide the mobile device, the mobile application,
and the mobile user with location information about themselves or other devices, applications,
and users.

7.2. Location Mobility


Using the Google Play services location APIs, your app can request the last known location
of the user’s device. In most cases, you are interested in the user’s current location, which is
usually equivalent to the last known location of the device.

Specifically, use the fused location provider to retrieve the device’s last known location. The
fused location provider is one of the location APIs in Google Play services. It manages the
underlying location technology and provides a simple API so that you can specify
requirements at a high level, like high accuracy or low power. It also optimizes the device’s
use of battery power.

Create location services client

In your activity’s onCreate() method, create an instance of the Fused Location Provider
Client as the following code snippet shows.

Java

private FusedLocationProviderClient fusedLocationClient;

@Override

protected void onCreate(Bundle savedInstanceState) {

fusedLocationClient = LocationServices.getFusedLocationProviderClient(this);

The getLastLocation() method returns a Task that you can use to get a Location object with
the latitude and longitude coordinates of a geographic location. The location object may
be null in the following situations:

 Location is turned off in the device settings. The result could be null even if the last location
was previously retrieved because disabling location also clears the cache.
 The device never recorded its location, which could be the case of a new device or a device
that has been restored to factory settings.
 Google Play services on the device has restarted, and there is no active Fused Location
Provider client that has requested location after the services restarted. To avoid this situation,
you can create a new client and request location updates yourself. For more information,
see Receiving Location Updates.

7.3. Location Based Service and Android


Google has a list of location-based services, including:

Google Location Accuracy for your Android device (a.k.a. Google Location
Services): To get a more accurate location for your phone, learn how to manage Location
Accuracy.

Emergency Location Service for your Android device: Learn how to manage Android
Emergency Location Service.

Earthquake alerts for your Android device: To get updates for nearby earthquakes on your
phone, learn how to manage Earthquake alerts.

Use location for time zone on your Android device: To get time zone updates based on
location, learn how to manage location for time zone.

Location History for your Google Account: To find and manage the places your phone has
been, learn how to turn on Location History.

Location Sharing for Google Maps: To let others know where your phone is, learn how to
share your real-time location via Google Maps.

Location in Search: To get more helpful results when you search on Google, learn how to
manage location permissions for websites and apps.

Wi-Fi scanning and Bluetooth scanning: To help apps get better location info, learn how to
scan for network or bluetooth devices.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy