Introduction To Mobile Computing With Android: Prof. Manish Kumar Joshi, Assistant Professor
Introduction To Mobile Computing With Android: Prof. Manish Kumar Joshi, Assistant Professor
Introduction To Mobile Computing With Android: Prof. Manish Kumar Joshi, Assistant Professor
with Android
Prof. Manish Kumar Joshi, Assistant Professor
IT & Computer Science
CHAPTER-4
Master Android Basics
Showing Alert Message to The User
We can show alert messages to the users in 2 different ways
1. Using Toast message
2. Using Alert Dialogue Box
Toast Message
A Toast is a feedback message. It takes a
very little space for displaying while overall
activity is interactive and visible to the user.
It disappears after a few seconds. It
disappears automatically.
Constants of Toast Class
• public static final int LENGTH_LONG
• public static final int LENGTH_SHORT
Method of Toast Class
• public static Toast makeText(Context context, CharSequence text, int
duration)
• public void show()
• public void setMargin (float horizontalMargin, float verticalMargin)
Alert Dialog Box
A Dialog is small window that prompts
the user to a decision or enter additional
information.
Alert Dialog Box
Some times in your application, if you
wanted to ask the user about taking a
decision between yes or no in
response of any particular action
taken by the user, by remaining in the
same activity and without changing
the screen, you can use Alert Dialog.
Method of Alert Dialog Box
• setIcon(Drawable icon)
• setCancelable(boolean cancel able)
• setMessage(CharSequence message)
• setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems,
DialogInterface.OnMultiChoiceClickListener listener)
• setOnCancelListener( DialogInterface.OnCancelListener
onCancelListener)
• setTitle(CharSequence title)
Intent and Passing Data Between Activities
An Android Intent is an abstract description of an operation to be
performed. It can be used with startActivity to launch an
Activity, broadcastIntent to send it to any interested BroadcastReceiver
components, and startService(Intent) or bindService(Intent,
ServiceConnection, int) to communicate with a background Service.
The intent itself, an Intent object, is a passive data structure holding an
abstract description of an operation to be performed.
Types of Intent
On Device Rotation
SaveInstanceState Example
After using SaveInstanceState
On Device Rotation
CheckBox
A CheckBox is an on/off switch that
can be toggled by the user. You
should use check-boxes when
presenting users with a group of
selectable options that are not
mutually exclusive.
CheckBox Attributes
Inherited from android.widget.TextView Class
• android:autoText
• android:drawableBottom
• android:drawableRight
• android:editable
• android:text
CheckBox Attributes
Inherited from android.view.View Class
• android:background
• android:contentDescription
• android:id
• android:onClick
• android:visibility
Seek Bar
Seek Bar is one of the very useful
user interface element in Android
that allows the selection of integer
values using a natural user
interface. An example of Seek Bar is
your device’s brightness control and
volume control.
Seek Bar Methods
• getMax
• getProgress
Seek Bar Attributes
• android:id
• android:max
• android:progress
• android:indeterminate
Rating Bar
Rating bar is a subclass of
absSeekbar class in android. It is
used to show the rating on view
Group or window manager.
Radio Button
A RadioGroup class is used for set
of radio buttons.
If we check one radio button that
belongs to a radio group, it
automatically unchecks any
previously checked radio button
within the same group.
Radio Button Attributes
Inherited from android.view.View Class
• android:background
• android:contentDescription
• android:id
• android:onClick
• android:visibility
Accessing Phones Services
Opening URL in a
browser from the
Android Application.
Accessing Phones Services
Making Call to Someone from Android
Application.
Before we can call on any number, in
order to access phones services we
need to ask user permissions first.
Accessing Phones Services
Now if the user has
allowed the permission
to make calls from the
application, we can now
use call functionality.
Accessing Phones Services
Same like as calling
someone from android
application we can also
open dialer pad of our
mobile phone.
Accessing Phones Services
We can also use mailing
service in our android
application, which will open
the default email application
of our android device.
www.paruluniversity.ac.in