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

Android WebView and Sensor Guide

This presentation presents an overview of web view and sensors in Android. The examples are illustrated in Android Studio with JAVA language.

Uploaded by

KAINAT FAROOQI
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 views31 pages

Android WebView and Sensor Guide

This presentation presents an overview of web view and sensors in Android. The examples are illustrated in Android Studio with JAVA language.

Uploaded by

KAINAT FAROOQI
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

WEB VIEW AND

SENSORS
GROUP MEMBERS
KAINAT FAROOQI…….62
SAFA SAEED...…..68
QIRAT QADEER.....…..31
Web View View
Website

Web View
Introduction
 WebView is an extension of the Android View class that displays web pages inside an activity.

 In general, it is used to display online content in android activity.

 WebView turns an application into a web application.

 It does not include any features of a fully developed web browser, such as navigation controls
or an address bar.
Advantages
 It is helpful when we want to provide information in the app that might need to be updated,
such as an end-user agreement or a user guide.

 It can help if the app provides data to the user that always requires an Internet connection to
retrieve, such as email. In this case, we might find that it's easier to build a WebView in the
Android app that shows a web page with all the user data, rather than performing a network
request, then parsing the data and rendering it in an Android layout.
Disadvantages
 Can have slow load times, and the page might jump around while loading in.

 Can lag.

 Web views might not work consistently on different versions of Android and/or iOS

 Web changes are harder, need testing in more places, and are more likely to break on different
platforms because of the need to support more platforms.
XML Code Structure

<WebView

android:layout_width="match_parent" or android:layout_width = “wrap_content”

android:layout_height="match_parent" or android:layout_height = “wrap_content”

android:id="@+id/webView“/>
Java Methods
Java Methods
EXAMPLE
XML File
Java File
Manifest File
For Internet connection permission
Output
Java File (Modification)
Output
What is the problem?

Everything is happening in ONE Activity!!!!!!!

Main Activity in After pressing Stack is empty

the foreground BACK button


Java File (Modification)
Output
SENSORS
Introduction
 It is a component used in mobile devices.

 It detects change in the environment (temperature, brightness etc.)

 It detects movements (device being flipped etc).

 It converts them into signals that can be processed by the device.


Types of Sensors
 Motion Sensors measure acceleration forces and rotational forces along three axes. This

category includes accelerometers, gravity sensors, gyroscopes, and rotational vector sensors.

 Position Sensors measure the physical position of a device. This category includes orientation

sensors and magnetometers.

 Environmental Sensors measure various environmental parameters, such as ambient air

temperature and pressure, illumination, and humidity. This category includes barometers,

photometers, and thermometers.


Sensor Framework Classes
 We can collect raw sensor data by using Android Sensor API. Some of the important classes

and interfaces are:

 SensorManager Class is used to access various sensors present in the device.

 Sensor Class is used to get information about the sensor such as sensor name, sensor type,

sensor resolution, sensor type, etc.

 SensorEvent class is used to find information about the sensor.

 SensorEventListener interface is used to perform some action when sensor accuracy changes.
Basic Sensors
Basic Sensors (Cont.)
 Accelerometers in mobile phones are used to detect the orientation of the phone.

 The gyroscope, or gyro for short, adds an additional dimension to the information supplied by

the accelerometer by tracking rotation or twist.

 The digital compass that's usually based on a sensor called the magnetometer and provides

mobile phones with a simple orientation in relation to the Earth's magnetic field. As a result,

your phone always knows which way is North so it can auto rotate your digital maps

depending on your physical orientation.


Basic Sensors (Cont.)
 Global Positioning System (GPS) is a sensor to help with navigation. It receives signals from

satellites that help calculate the distance traveled and the location of your phone. When a signal

is received, the GPS sensor records a location.

 light sensors are used to automatically adjust screen brightness based on light levels. for

example, making the screen brighter and easier to see in direct sunlight.

 The barometer assists the GPS inside the device to get a faster lock by instantly delivering

altitude data.
EXAMPLE
XML File
Java File
Output
THANK YOU

You might also like