Module 5

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Course Details

Course Code : CSE 3075

Course Name: Mobile Application Development [MAD]


Credit Structure: 3 Credits (L=1, P=4, C=3)

Instructor In-Charge & Instructor: Ms. B Prema Sindhuri


& Dr. Blessed Prince

1
MODULE 5
Advance App Development – Application Level (15 hrs)
Lecture Hours: 5 and Practical Hours: 10

Topics Covered:
• Graphics, Course Outcome Achievable:
• Animation, C.O. 5: Use multimedia and internet services for
mobile applications.
• Email,
• SMS
• Location Based Services

2
Graphics
The Android framework offers a variety of graphics rendering APIs for 2D and 3D
that interact with manufacturer implementations of graphics drivers, so it is
important to have a good understanding of how those APIs work at a higher level.

Android Rendering Options


• Canvas API
• RenderScript
• OpenGL Wrappers
• NDK OpenGL

3
Canvas API
• Standard rendering for a typical SDK application that uses View objects (standard
and custom)
• Consists of calls to each Views onDraw() method. This method takes a single
parameter, Canvas, which is the object used by the view to draw its content
Renderscript
• Introduced in Android 3.0. API targeted high- performance 3D rendering and
compute operations
• Executing native code on the device still cross-platform
• Use of extensions that are placed into the application package.
• RenderScript is especially useful for applications performing image processing,
computational photography, or computer vision.

4
Open GL Wrappers
• Open GL APIs at the SDK Level. It is not recommended practice as a general
approach for complex scenes that require high- performance graphics
• Music application that shipped with Android 3.0, used this approach

NDK Open GL
• No access to the View objects, or the events, or the rest of the infrastructure that
is provided in the SDK APIs
• Graphics environment sufficient for some specific purposes: game developers
• Compiles applications to specific CPU architectures

5
Animations
• Animation API was introduced by Google in Android 3.0 which gives us the
flexibility to change object properties over a certain time interval. The animation
framework allows us to create visually attractive animations and transitions in
our apps.
Type of Animation:
• View Animation: View Animation can be used to add animation to a specific view to perform
tweened animation on views. Tween animation calculates animation information such as size,
rotation, start point, and endpoint.
• Property Animation: Property Animation is one of the robust frameworks which allows
animating almost everything. Eg: change anim postion, duration etc.
• Drawable Animation: Drawable Animation is used if you want to animate one image over
another. The simple way to understand is to animate drawable is to load the series of drawable
one after another to create an animation.

6
Animation Methods:
The Animation class has many methods given below:
• start(): This method will start the animation
• setDuration(long duration): This method sets the duration of an animation
• getDuration(): This method gets the duration
• end(): This method ends the animation
• Cancel(): This method cancels the animation

7
Animation File in Android Studio
To apply animations to our application sometimes we need to make an anim folder in
android studio to store animation file under the resource folder of our application.
Basically there are two options for resource types:
animator/-XML files that define property animations.
anim/-XML files that define tween animations
Common Properties:

8
Sending an Email
Sending Emails can also be implemented using Android. Email is just like a
message that can be sent from one user to another user via a network. In Android,
you can send an email from your application without implementing it, just by using
the default Email app provided by android like Email, Gmail, Outlook etc.
There are different Intent objects required to send an email that is described
below:
Action required to send Email: To launch an email client on your android device,
you will have to use ACTION_SEND action. The syntax given below is used to create
an intent:
Intent mailAction = new Intent(Intent.ACTION_SEND);

9
Sending an Email (Contd..)
Type to send mail: As we are familiar with sending mail where you need to specify where
you need to send the mail, i.e. ‘mailto:’. Here we provide the URI of the recipient with the
help of the setData() method. You can also follow the code snippet shown below for your
reference where we also defined the setType() method:
emailIntent.setData(Uri.parse(“mailto:”));
emailIntent.setType(“text/plain”);
Attachments in the mail or other extras: Android comes with default support where you
can use TO, SUBJECT, CC, BCC etc. fields in your mail without sending it to the main
recipient. Refer to the example below for a better understanding:
emailIntent.putExtra(Intent.EXTRA_EMAIL , new String[]{"Recipient_Add"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject_Here");
emailIntent.putExtra(Intent.EXTRA_TEXT , "This is the main body of the mail.");

10
Sending SMS
In android, we can send SMS from our android application in two ways either by using
SMSManager API or Intents based on our requirements.
If we use SMSManager API, it will directly send SMS from our application. In case if we use Intent
with proper action (ACTION_VIEW), it will invoke a built-in SMS app to send SMS from our
application.
Sending SMS using SMSManager:
In android, to send SMS using SMSManager API we need to write the code like as shown below.
SmsManager smgr = SmsManager.getDefault();
smgr.sendTextMessage(MobileNumber,null,Message,null,null);
SMSManager API required SEND_SMS permission in our android manifest to send SMS. Following
is the code snippet to set SEND_SMS permissions in manifest file.
<uses-permission android:name="android.permission.SEND_SMS"/>

11
Sending SMS using Intent
To send SMS using the Intent object, we need to write the code like as shown below.
Intent sInt = new Intent(Intent.ACTION_VIEW);
sInt.putExtra("address", new String[]{txtMobile.getText().toString()});
sInt.putExtra("sms_body",txtMessage.getText().toString());
sInt.setType("vnd.android-dir/mms-sms");
Even for Intent, it required a SEND_SMS permission in our android manifest to send SMS.
Following is the code snippet to set SEND_SMS permissions in manifest file.
<uses-permission android:name="android.permission.SEND_SMS"/>

12
Location Based Services
• Location-Based Services(LBS) are present in Android to provide you with
features like current location detection, display of nearby places, geofencing, etc.
It fetches the location using your device’s GPS, Wifi, or Cellular Networks.

• To build an app with location-based services, you need to access the Google Play
Services Module. After that, you need to use a framework called Location
Framework, which has many methods, classes, and interfaces to make your task
easier.

13
Components of Location Based Services
• The classes and the interfaces present in the Location Framework acts as the
essential components for LBS. Those components are as follows:

• LocationManager Class – It is used to get Location Service access from the system.
• LocationListener Interface – It receives updates from the Location Manager class.
• LocationProvider – It is the class that provides us with the location for our
devices.
• Location Class – Its objects carry information about the location. The information
includes latitude, longitude, accuracy, altitude, and speed.

14
END OF MODULE 5

15
Thank You

16

You might also like