Professional Documents
Culture Documents
MAD LectureNotes
MAD LectureNotes
MAD LectureNotes
Avinash Chaudhari
History
• Android is an open source and Linux-based Operating System for mobile
devices such as smartphones and tablet computers.
• Android was developed by the Open Handset Alliance, led by Google, and
other companies.
• The rst beta version of the Android Software Development Kit (SDK) was
released by Google in 2007.
• Media support: H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC,
AAC 5.1, MP3, MIDI, Ogg Vorbis, WAV, JPEG, PNG, GIF, and BMP.
• Multi-touch: Android has native support for multi-touch which was initially
made available in handsets such as the HTC Hero.
• Multi-tasking: User can jump from one task to another and same time
various application can run simultaneously.
• For example, an email application might have one activity that shows a list of
new emails, another activity to compose an email, and another activity for
reading emails.
• If an application has more than one activity, then one of them should be
marked as the activity that is presented when the application is launched.
}
Services
• A service is a component that runs in the background to perform long-running
operations.
• For example, a service might play music in the background while the user is in
a di erent application,
• or it might fetch data over the network without blocking user interaction with
an activity.
}
ff
ServicesBroadcast Receivers
• Broadcast Receivers simply respond to broadcast messages from other
applications or from the system.
• For example, applications can also initiate broadcasts to let other applications
know that some data has been downloaded to the device and is available for
them to use, so this is broadcast receiver who will intercept this communication
and will initiate appropriate action.
}
Content Providers
• A content provider component supplies data from one application to others on
request.
}
fi
Additional Components
• Fragments: Represents a portion of user interface in an Activity.
• Views: UI elements that are drawn on-screen including buttons, lists forms
etc.
• Layouts: View hierarchies that control screen format and appearance of the
views.
Avinash Chaudhari
Android UI
• Android provides a variety of Pre-built UI components.
• Layout objects and UI controls that allow you to build the graphical user
interface for your app.
• Android also provides other UI modules for special interfaces such as dialogs,
noti cations, and menus.
fi
View Group
• A ViewGroup is a special view that can contain other views (called children.)
• The view group is the base class for layouts and views containers.
• It’s child can be Views or View Group.
Views
• View class represents the basic building block for user interface components.
• A View occupies a rectangular area on the screen and is responsible for
drawing and event handling.
• A View usually draws something the user can see and interact with.
• Layout(View Group) is an invisible container that de nes the layout structure
for View and other Layout(View Group) objects.
• You can specify the layout direction with the android:orientation attribute.
• Linear Layout can be created in two direction: Horizontal &
Vertical.
fi
Relative Layout
• RelativeLayout is a view group that displays child views in relative positions.
• The position of each view can be speci ed as relative to sibling elements or in
positions relative to the parent RelativeLayout area.
• In this the child views are added in a stack and the most
recently added child will show on the top.
Table Layout
• Android TableLayout arranges groups of views into rows
and columns.
fl
Constraint Layout
Attribute Description
android:typeface Typeface (normal, sans, serif, monospace) for the text. You can use or more of the values separated by
'|'. normal – 0, sans – 1, serif – 2, monospace – 3.
EditText
• An EditText is an overlay over TextView that con gures itself to be editable.
• It is the prede ned subclass of TextView that includes rich editing capabilities.
Attribute Description
android:autoText TextView has a textual input method and automatically corrects some common
spelling errors.
android:inputType The type of data being placed in a text field. Phone, Date, Time, Number, Password
etc.
android:hint Hint text to display when the text is empty.
• Every button is styled using the system's default button background it can customize.
Attribute Description
android:onClick This is the name of the method in this View's context to invoke when the view is
clicked.
Toast
• Android Toast can be used to display information for a short period of time.
• A toast contains a message to be displayed quickly and disappears after some time.
• It doesn't block user interaction.
Toast.makeText(getApplicationContext(),"Hello World”,Toast.LENGTH_SHORT)
.show();
ToggleButton
• Android Toggle Button can be used to display checked/unchecked (On/O ) state on
the button.
• It is bene cial if user have to change the setting between two states. It can be used to
On/O Sound, Wi , Bluetooth etc.
Method Description
CharSequence getTextO () Returns the text when button is not in the checked state.
CharSequence getTextOn() Returns the text for when button is in the checked state.
Avinash Chaudhari
Audio, Video, Camera
MediaPlayer
fi
MediaPlayer
Audio, Video, Camera
• The ovals represent the states a MediaPlayer object may reside in.
• The arcs represent the playback control operations that drive the object state
transition.
• The arcs with a single arrow head represent synchronous method calls.
• The double arrow head represent asynchronous method calls.
• setOnBu eringUpdateListener()
• seekTo(long, int)
ff
Methods
mediaPlayer = MediaPlayer.create(this,R.raw.kalimba);
mediaPlayer.start();
mediaPlayer.pause();
mediaPlayer.reset();
mediaPlayer.isPlaying();
mediaPlayer.seekTo(position);
mediaPlayer.getCurrentPosition();
mediaPlayer.getDuration();
mediaPlayer.setDataSource(R.raw.kalimba);
mediaPlayer.selectTrack(index);
mediaPlayer.release();
Video Player
• Using MediaController and VideoView classes, we can play the video les in
android.
• VideoView class provides methods to play and control the video player.
fi
Methods of VideoView
• setMediaController(MediaController controller)
• setVideoUri(Uri uri)
• start()
• stopplayback()
• pause()
• suspend()
• resume()
• seekTo()
VideoView
<VideoView
android:id="@+id/videoView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true" />
Activity
//Creating MediaController
MediaController mediaController= new MediaController(this);
mediaController.setAnchorView(videoView);