Chapter - 6

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

2024

Mobile Application Development


Prepared By: Zakiyos lencha (MSc.)
Chapter Six
6. Graphics and multimedia Graphics
6. 1. Introduction
After completing this chapter, Students must able to:

 Describe performance and multithreading


 Explain multimedia
 Understand mobile agents and peer-to-peer architecture

Graphics provides one of the most natural means of communicating with a computer, since our
highly developed 2D and 3D pattern-recognition abilities allow us to perceive and process
pictorial data rapidly and efficiently. In Many design, implementation, and construction
processes today, the information pictures can give is virtually indispensable. Scientific
visualization became an important field in the late 1980s, when scientists and engineers
realized that they could not interpret the data and prodigious quantities of data produced in
supercomputer runs without summarizing the data and highlighting trends and phenomena in
various kinds of graphical representations.

Creating and reproducing pictures, however, presented technical problems that stood in the
way of their widespread use. Thus, the ancient Chinese proverb “a picture is worth ten thousand
words” became a cliché in our society only after the advent of inexpensive and simple
technology for producing pictures—first the printing press, then Photography. Interactive
computer graphics is the most important means of producing pictures since the invention of
photography and television; it has the added advantage that, with the computer, we can make
pictures not only of concrete, “real-world” objects but also of abstract, synthetic objects, such
as mathematical surfaces in 4D and of data that have no inherent geometry, such as survey
results. Furthermore, we are not confined to static images. Although static pictures are a good
means of communicating information, dynamically varying pictures are frequently even
better–to time-varying phenomena, both real (e.g., growth trends, such as nuclear energy use
in the United States or population movement form cities to suburbs and back to the cities).
Thus, a movie can show changes over time more graphically than can a sequence of slides.
Thus, a sequence of frames displayed on a screen at more than 15 frames per second can convey
smooth motion or changing form better than can a jerky sequence, with several seconds
between individual frames. The use of dynamics is especially effective when the user can
control the animation by adjusting the speed, the portion of the total scene in view, the amount
of detail shown, the geometric relationship of the objects in the another, and so on. Much of
interactive graphics technology therefore contains hardware and software for user-controlled
motion dynamics and update dynamics. With motion dynamics, objects can be moved and
tumbled with respect to a stationary observer. The objects can also remain stationary and the
viewer can move around them. Pan to select the portion in view, and zoom in or out for more
or less detail, as though looking through the viewfinder of a rapidly moving video camera. In
many cases, both the objects and the camera are moving. A typical example is the flight
simulator, which combines a mechanical platform supporting a mock cockpit with display
screens for windows.

Computers control platform motion, gauges, and the simulated world of both stationary and
moving objects through which the pilot navigates. These multimillion-dollar systems train
pilots by letting the pilots maneuver a simulated craft over a simulated 3D landscape and
around simulated vehicles. Much simpler flight simulators are among the most popular games
on personal computers and workstations. Amusement parks also offer “motion-simulator” rides
through simulated terrestrial and extraterrestrial landscapes. Video arcades offer graphics-
based dexterity games and racecar-driving simulators, Video Games exploiting interactive
motion dynamics: The player can change speed and direction with the “gas pedal” and “steering
wheel,” as trees, buildings, and other cars go whizzing by. Similarly, motion dynamics lets the
user fly around the through buildings, molecules, and 3D or 4D mathematical space. In another
type of motion dynamics, the “camera” is held fixed, and the objects in the scene are moved
relative to it. For example, a complex mechanical linkage, such as the linkage on a stream
engine, can be animated by moving or rotating all the pieces appropriately. Update dynamics
is the actual change of the shape, color, or other properties of the objects being viewed. For
instance, a system can display the deformations of an airplane structure in flight or the state
changes in a block diagram of a nuclear reactor in response to the operator’s manipulation of
graphical representations of the many control mechanisms. The smoother the change, the more
realistic and meaningful the result. Dynamic interactive graphics offers a large number of user-
controllable modes with which to encode and communicate information: the 2D or 3D shape
of objects in a picture, their gray scale or color, and the time variations of these properties.
With the recent development of digital signal processing (DSP) and audio synthesis chips,
audio feedback can now be provided to augment the graphical feedback and to make the
simulated environment even more realistic. Interactive computer graphics thus permits
extensive, high-bandwidth user-computer interaction. This significantly enhances our ability
to understand data, to perceive trends, and to visualize real or imaginary objects–indeed, to
create “virtual worlds” that we can explore from arbitrary points of view. By making
communication more efficient, graphics make possible higher-quality and more precise results
or products, greater productivity, and lower analysis and design costs.

6.2. Graphics and multimedia Graphics


The use of computer graphics is wide spread. It is used in various areas such as industry,
business, government organizations, education, entertainment and most recently the home. Let
us discuss representative uses of computer graphics in brief. User friendliness is one of the
main factors underlying the success and popularity of any system. It is now a well-established
fact that graphical interfaces provide in attractive and easy interaction between users and
computers. The built-in graphics provided with user interfaces use visual control items such as
buttons, menus, icons, scroll bar etc, which allows user to interact with computer only by
mouse-click. Typing is necessary only to input text to be stored and manipulated. In industry,
business, government and educational organizations, computer graphics is most commonly
used to create 2D and 3D graphics of mathematical, physical and economic functions in form
of histograms, bars, and pie-chats. These graphs and charts are very useful for decision making.
The desktop publishing on personal computers allows the use of graphics for the creation and
dissemination of information. Many organizations do the in-house creation and dissemination
of documents. The desktop publishing allows user to create documents which contain text,
tables, graphs, and other forms of drawn or scanned images or pictures. This is one approach
towards the office automation. The computer-aided drafting uses graphics to design
components and systems electrical, mechanical, electromechanical and electronic devices such
as automobile bodies, structures of building, airplane, slips, very large-scale integrated chips,
optical systems and computer networks. Use of graphics in simulation makes mathematic
models and mechanical systems more realistic and easier to study. The interactive graphics
supported by animation software proved their use in production of animated movies and
cartoons films. There is lot of development in the tools provided by computer graphics. This
allows user to create artistic pictures which express messages and attract attentions. Such
pictures are very useful in advertising. By the use of computer now it is possible to control
various processes in the industry from a remote-control room. In such cases, process systems
and processing parameters are shown on the computer with graphic symbols and identification.
This makes it easy for operator to monitor and control various processing parameters at a time.

 Interactive Computer Graphics

In interactive computer graphics, users have some control over the picture i.e. user can make
any changes or alterations in the produced image. One example of it is the ping pong game. At
the hardware level, a computer receives input from interaction devices and outputs images to a
display device.

The software has three components. The first is the application program, it creates, stores into,
and retrieves from the second component, the application model, which represents the graphic
primitive to be shown on the screen. The application program also handles user input. It
produces views by sending to the third component, the graphics system, a series of graphics
output commands that contain both a detailed geometric description of what is to be viewed
and the attributes describing how the objects should appear.

 Passivecomputer Graphics–

Passive computer graphics is an operation on computer graphics that transfers automatically


and without operator intervention. Non-interactive computer graphics or passive computer
graphics involves one-way communication between the computer and the user. The picture is
produced on the monitor and the user does not have any control over the produced picture.

Applications Of Computer Graphics –

Computer graphics has numerous of diverse applications listed in the previous section which
differ in a variety of ways, and a number of classification is by type (dimensionality) of the
object to be represented and the kind of picture to be produced. Furthermore, computer graphics
is used today in many different areas of industry, business, government, education,
entertainment, and most recently, the home. The list of applications is enormous and is growing
rapidly as computers with graphics capabilities become commodity products. Let`s have a look
at a representative sample of these areas:
1. Cartography
2. User interfaces
3. Plotting in Business, Science, and Technology
4. Office automation and electronic publishing
5. Computer-aided drafting and design
6. Art and Commerce
7. Process control

Multimedia Applications –

As the name suggests, multimedia is a set of more than one media element used to produce a
concrete and more structured way of communication. Multimedia is nothing but the processing
and presentation of information in a more structured and understandable manner using more
than one media such as text, graphics, animation, audio, and video.

Multimedia Software :

Multimedia software is sometimes broadly grouped as:

1. a)Multimedia Authoring Tools


2. b)Multimedia Tools for the Web
3. c)Multimedia Presentation Software

 Multimedia Hardware :

For producing multimedia you need hardware, software, and creativity. Thus, following are the
specific multimedia hardware:

1. Central Processing Unit


2. Monitor
3. Video Grabbing Card
4. Sound Card
5. CD-ROM Drive
6. Scanner
7. Touchscreen
Components Of Multimedia –

1. Text
2. Graphics
3. Animation
4. Video

6.3. Performance and Multithreading


Developers’ multithread Android applications in order to improve their performance and
usability. By spinning off processor- or resource-intensive tasks into their own threads, the rest
of the program can continue to operate while these processor intensive tasks finish working.
This can include separating the thread for the graphical user interface from the threads that
fetch network data. The JVM automatically manages these multiple tasks, so Android
developers do not have to concern themselves with optimizing thread performance for a
particular set of hardware.

Android can use multiple CPU cores for multithreading, but the kernel and JVM handle that
process, not the developer himself. An internal multithreading design will improve the
program’s basic performance, but the device upon which it actually runs will determine its
speed.

Working on multiple tasks at the same time is Multitasking. In the same way, multiple threads
running at the same time in a machine is called Multi-Threading. Technically, a thread is a
unit of a process. Multiple such threads combine to form a process. This means when a process
is broken, the equivalent number of threads are available.
For example, Autocorrect is the process where the software looks for the mistakes in the
current word being typed. Endlessly checking for the mistake and providing suggestions at the
same time is an example of a Multi-Threaded process.

Sample Android App:

Let’s try to visualize Multi-Threading with the help of an Android App. In the below example,
3 Threads start at the same time on a button click and work concurrently.
Approach:
Step 1: Add the below code in activity_main.xml. Here we add three TextViews and a button.

XML

<?xml version="1.0" encoding="utf-


8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/andro
id" xmlns:app="http://schemas.android.com/apk/res-
auto" xmlns:tools="http://schemas.android.com/tools" android:layout_wid
th="match_parent" android:layout_height="match_parent" tools:
context=".MainActivity"> <TextView android:id="@+id/tv1"
android:layout_width="75sp" android:layout_height="7
5sp" android:background="@color/colorPrimary" android
:textColor="@color/colorAccent" android:gravity="center"
android:textSize="10sp" android:layout_centerVertical="t
rue" android:layout_toLeftOf="@id/tv2" /> <TextVie
w android:id="@+id/tv2" android:layout_width="75sp"
android:layout_height="75sp" android:background="@colo
r/colorPrimary" android:textColor="@color/colorAccent"
android:gravity="center" android:textSize="10sp" an
droid:layout_centerI nParent="true" /> <TextView
android:id="@+id/tv3" android:layout_width="75sp" and
roid:layout_height="75sp" android:background="@color/colorPr
imary" android:textColor="@color/colorAccent" android
:gravity="center" android:textSize="10sp" android:lay
out_centerVertical="true" android:layout_toRightOf="@id/tv2"
/> <Button android:id="@+id/btnStart" andr
oid:layout_width="wrap_content" android:layout_height="wrap_
content" android:text="Start" android:layout_centerHo
rizontal="true" android:layout_below="@id/tv2" /> </Re
lativeLayout>

Step 2: Add the below code in MainActivity. Here, three threads are made, each thread keeps
updating the respective TextView every second (declared in the code) when the button is
clicked. These Threads keep running until the button is clicked again (i.e.”Stop”).

 Java

class MainActivity : AppCompatActivity()


{ @SuppressLint("SetTextI18n") override fun
onCreate(savedInstanceState:
Bundle?) { super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) // Assigning
Layout elements val tv1 =
findViewById<TextView>(R.id.tv1) val
tv2 =
findViewById<TextView>(R.id.tv2) val
tv3 =
findViewById<TextView>(R.id.tv3) val
btn = findViewById<Button>(R.id.btnStart) //
Boolean for Button (initially False) var
boolbtn = false // Button onClick
action btn.setOnClickListener { //
Button (True) boolbtn = !boolbtn //
Case where Button is
False if (!boolbtn) {
tv1.text = "Stopped1" tv2.text =
"Stopped2" tv3.text =
"Stopped3" btn.text =
"Start" } // Case where Threads are
running else { // Setting the
button text as "Stop" btn.text =
"Stop" // Thread
1 Thread(Runnable
{ // Runs only when Button is
True while (boolbtn)
{ runOnUiThread
{ tv1.text =
"Started1" }
Thread.sleep(1000)
runOnUiThread {
tv1.text =
"Activity1" }
Thread.sleep(1000) }
}).start() //
Thread 2 Thread(Runnable
{ // Runs only when Button
is //
True while (boolbtn)
{ runOnUiThread
{ tv2.
text =
"Started2" }
Thread.sleep(1000)
runOnUiThread {
tv2.text =
"Activity2" }
Thread.sleep(1000)
} }).start()
// Thread 3 Thread(Runnable
{ // Runs only when Button
is //
True while (boolbtn)
{ runOnUiThread
{
tv3.text =
"Started3" }
Thread.sleep(1000)
runOnUiThread
{ tv3.text =
"Activity3" }
Thread.sleep(1000)
} })
.start() } } }}

6.4. Graphics and UI Performance


The user interface of your app is likely influenced by designers, developers, usability studies,
and testing—just about anyone is happy to add input/feedback to how your app looks. As the
UI of your app is your connection to your customers, it defines your brand and it requires
careful planning. However simple (or complicated) the UI of your app is, it’s important that
your UI design is built to be performant.
As a developer, your task is to work with the UI/UX team and build an app that follows its
design parameters on every Android device. We’ve already (briefly) discussed the pitfalls of
the many screen sizes in the Android ecosystem and the challenges that exist there. But how
about UI performance? How does the UI that your designers designed (and you built) run? Do
the pages load quickly? Do they respond in a fast and smooth way? In this chapter, we’ll discuss
how to optimize your UI for fast rendering and scrolling/animations, and the tools you can use
to profile your screen and UI performance.

UI Performance Benchmarks

Like all performance goals, it is important to understand the performance goals associated with
UI. Saying “my app needs to load faster” is great, but what are the expectations of the end user,
and are there concrete numbers you can apply to those expectations? In general, we can fall
back on studies of the psychology of human interactions. These studies have shown that users
perceive delays of 0 – 100 ms as instantaneous and delays of 100 – 300 ms as sluggish; delays
between 300 – 1,000 ms indicate to users that “the machine is working,” whereas delays of
1,000+ ms lead users to feel a context switch.

As this is basic human psychology, it seems to be a good metric to start with for page/view/app
loading times. Ilya Grigorik has a great presentation about building mobile websites to take
just “1,000 ms to Glass.” If your web page can load in 1 second, you win the human perception
battle, and now you must wow your customers with great content. Additional research has
shown that >50% of users begin abandoning websites if no content has loaded in 3–4 s.
Applying the same argument to apps tells us that the faster you can get your app to start, the
better. In this chapter, we’ll focus just on the UI loading. There may be tasks that must run in
the background, files to be downloaded from the Internet, and so on, we’ll cover optimizing
these tasks (or ways to keep these tasks from blocking the rendering) in future chapters.

Jank

In addition to getting content on the screen as quickly as possible, it has to render in a smooth
way. The Android team refers to jerky, unsmooth motion as jank, and this is caused by missing
a screen frame refresh. Most Android devices refresh the screen 60 times a second (there are
undoubtedly exceptions—earlier Android devices were sometimes in the 50 or less fps range).
Because the screen is refreshed every 16 ms (1 s/60 fps = 16 ms per frame), it is crucial to
ensure that all of your rendering can occur in less than 16 ms. If a frame is skipped, users
experience a jump or skip in the animation, which can be jarring. In order to keep your
animations smooth, we’ll look at ways to ensure the entire screen renders in 16 ms. In this
chapter, we’ll diagnose common issues and illustrate how to remove jank from your UI.

UI and Rendering Performance Updates in Android

One of the major complaints of early Android releases was that the UI—especially touch
interactions and animations—were laggy. As a result, as Android has matured, the developers
have invested a great deal of time and effort to make the user interaction as fast and seamless
as possible. Let’s walk through a few of the improvements that have been added in various
releases of Android to improve the user interaction:

 On devices running Gingerbread or earlier, the screen was drawn completely in software (there was no
GPU requirement). However, device screens were getting larger and pixel density was increasing,
placing strain on the ability of the software to render the screen in a timely manner.
 Honeycomb added tablets, further increasing screen sizes. To account for this, GPU chips were added,
and apps had the option to run the rendering using full GPU hardware acceleration.
 For apps targeting Ice Cream Sandwich and higher, GPU hardware acceleration is on by default;
pushing most rendering out of the software and onto dedicated hardware sped up rendering
significantly.
 Jelly Bean 4.1 (and 4.2) “Project Butter” made further improvements to avoid jank and jitter, in order
to make your apps “buttery smooth.” By improving timing with VSYNC (better scheduling frame
creation) and adding additional frame buffering, Jelly Bean devices skip frames less often. When
building these improvements, the Android team built a number of great tools to measure screen drawing,
the new VSYNC buffering and jank, and released these tools to developers.

We’ll review all of these changes, the tools introduced, and what they mean to the average
Android developer. As you might imagine, the goals from these updates were as follows:

 Lower the latency of screen draws


 Create fast, consistent frame rates to avoid jank
When the Android team was working on all of the improvements to screen rendering and UI
performance, they needed tools to quantify the improvements that they made to the OS. To
their credit, they have included these tools in the Android SDK so that developers can test their
apps for rendering performance issues. As we walk through the different ways to improve app
performance, we’ll use these tools with example apps to explain how they work.

Building Views

I assume that you are familiar with the XML layout builder in Android Studio, and how to
build views with the different tools in Android Studio (Eclipse) to look at those views.
In Figure 4-1, you can see a simple app with a series of nested views. When building your
views, it is important to look at the Component Tree in the upper-right of the screen. The more
nested your views become, the more complicated the View Tree becomes, and the longer it
will take to render.
For each view in your app, Android goes through three steps to render on the screen: measure,
layout, and draw. If you imagine your XML layout hierarchy in your app, the measure starts at
the top node and walks the render tree of the layout: measuring the dimensions of each view to
be displayed on the screen (in : LinearLayout; RelativeLayout; LinearLayout; then branching
for textView0 and the LinearLayout Row1—which has three further children). Each view will
provide dimensions to the parent for positioning. If a parent view discovers an issue in the
measurements of its dimensions (or that of its children), it can force every child (grandchild,
great-grandchild, etc.) to remeasure in order to resolve the issue (potentially doubling or
tripling the measurement time). This is the reason a flat (less nested) view tree is valuable. The
deeper the nodes for the tree, the more nested the measurement, and the calculation times are
lengthened (especially on remeasurements). We’ll examine some examples of how
remeasurement can really hurt rendering as we look through the views.

Remeasuring Views

There does not have to be an error for a remeasure to occur. RelativeLayouts often have to
measure their children twice to ensure that all child views are laid out properly. LinearLayouts
that have children with layout weights also have to measure twice to get the exact dimensions
for the children. If there are nested LinearLayouts or RelativeLayouts, the measure time can
grow in an exponential fashion (four remeasures with two nested views, eight remeasures with
three nested views, etc.).

Once the views are measured, each view will layout its children, and pass the view up to its
parent—all the way back up to the root view. Once the layout is completed, each view will be
drawn on the screen. Note that all views are drawn, not just the ones that are seen by your
customers. We’ll talk about that issue in “Overdrawing the Screen”. The more views your app
has, the more time it will take to measure, layout, and draw. To minimize the time this takes,
it is important to keep the render tree as flat as possible, and remove all views that not essential
to rendering. Removing layers of the layout tree will go a long way in speeding up the painting
of your screen. Ideally the total measure, layout, and draw should be well below the 16 ms
threshold—ensuring smooth scrolling of your UI on the screen.
While it is possible to look at the node view of your layout as XML (like in Figure 4-1), it can
be difficult to find redundant views. In order to find these redundant views (and views that add
delay to screen rendering), the Hierarchy Viewer tool in Android Studio Monitor can greatly
help you visualize the views in your Android app to resolve these issues (Monitor is a
standalone app that is downloaded as a part of Android Studio).

Hierarchy Viewer

The Hierarchy Viewer is a handy way to visualize the nesting behavior of your various views
on a screen. The Hierarchy Viewer is a great tool to investigate the construction of your view
XML. It is available in Android Studio Monitor, and requires a device with a developer build
of Android on it. See “Rooted Devices/Engineering/Developer Builds” for details on what this
entails. There is also a class from Googler Romain Guy that allows you to test a debug version
of your app. All of the views and screenshots using the Hierarchy View in the subsequent
sections are taken from a Samsung Note II running 4.1.2 Jelly Bean. By testing screen rendering
on an older device (with a slower processor), you can be sure that if you meet rendering
thresholds on this device, your app will likely render well on all Android devices.

6.5. Android Graphics


Android provides a huge set of 2D-drawing APIs that allow you to create graphics.

Android has got visually appealing graphics and mind blowing animations.

The Android framework provides a rich set of powerful APIS for applying animation to UI
elements and graphics as well as drawing custom 2D and 3D graphics.

Following are the three animation systems used in Android applications:

1. Property Animation

2. View Animation

3. Drawable Animation

1. Property Animation
 Property animation is the preferred method of animation in Android.
 This animation is the robust framework which lets you animate any properties of any objects,
view or non-view objects.
 The android.animation provides classes which handle property animation.

2. View Animation

 View Animation is also called as Tween Animation.


 The android.view.animation provides classes which handle view animation.
 This animation can be used to animate the content of a view.
 It is limited to simple transformation such as moving, re-sizing and rotation, but not its
background color.

3. Drawable Animation

 Drawable animation is implemented using the AnimationDrawable class.


 This animation works by displaying a running sequence of ‘Drawable’ resources that is
images, frame by frame inside a view object.
 Canvas
 Android graphics provides low level graphics tools such as canvases, color, filters, points and
rectangles which handle drawing to the screen directly.
 The Android framework provides a set of 2D-DRAWING APIs which allows user to provide
own custom graphics onto a canvas or to modify existing views to customize their look and
feel.

There are two ways to draw 2D graphics,

1. Draw your animation into a View object from your layout.


1. Draw your animation directly to a Canvas.

Some of the important methods of Canvas Class are as follows

i. drawText() drawRoundRect() drawCircle() drawRect() drawBitmap()drawARGB()


ii. You can use these methods in onDraw() method to create your own custom user interface.
iii. Drawing an animation with a View is the best option to draw simple graphics that do not
need to change dynamically and are not a part of a performance-intensive game. It is used
when user wants to display a static graphic or predefined animation.
iv. Drawing an animation with a Canvas is better option when your application needs to re-draw
itself regularly. For example video games should be drawing to the Canvas on its own.

Example

What is it about?

Create a new Java class that should extend from View class. Override the onDraw() method.
In this method, you can use Canvas class to draw the different shapes.

File name: MyView.java

public class MyView extends View

{
public MyView(Context context)

{
super(context);

// TODO Auto-generated constructor stub

}
@Override
protected void onDraw(Canvas canvas)

// TODO Auto-generated method stub

super.onDraw(canvas);
int radius;
radius = 50;

Paint paint = new Paint();

paint.setStyle(Paint.Style.FILL);

paint.setColor(Color.parseColor(“#CD5C5C”));

canvas.drawCircle(150,200, radius, paint);

canvas.drawRoundRect(newRectF(20,20,100,100), 20, 20, paint);

canvas.rotate(-45);

canvas.drawText(“TutorialRide”, 40, 180, paint);

canvas.restore();

}
}

6.6. Multimedia Mobile Agents and Peer-to-Peer Architecture


Peer-to-peer (P2P) content-distribution applications are widely spread on stationary computers
in fixed networks today. But also mobile devices (MDs) in cellular radio networks, e.g. phones
or personal digital assistants, are potential candidates for participating in these popular P2P
networks. Their integration into popular P2P content-distribution networks (CDNs) with large
user communities is a special instance of the mobile peer-to-peer (mobile P2P) research field.
Although current MDs mostly have enough hardware resources to join such P2P networks,
they are barely able to benefit from them. Their participation together with a large number of
stationary computers with high-bandwidth links, increases heterogeneity within P2P networks,
which causes performance problems, especially for MDs. In contrast to this heterogeneity, P2P
systems apply homogeneous logical structures (the overlay), in which computers and links are
considered to be equal, having similar properties and capabilities.

Mobile P2P approaches that focus on cellular radio networks are partitioned in three categories
with respect to the support they provide to MDs: 1) no additional support, 2) support from the
P2P protocol, and 3) other support not being part of the P2P protocol. No support: Solutions of
this category are reshaping P2P client software to the requirements of MDs, considering the
MDs limitations, whereas the P2P protocol remains unchanged. MDs join P2P networks as
ordinary peers without getting further support. In this paper, this approach is called the
straightforward approach or no support solution. Symella (http://symella.aut.bme.hu), e.g., is
such a P2P client for the Gnutella [2] P2P file-sharing network.

Components
We have to consider not only the distribution of learning contents but also the distribution of
functions to provide above services. Our system consists of mobile agents and user interface
program. In our system, functions are provided as the part of mobile agent. A mobile agent
migrates from one node to another node with a function it provides. These mobile agents are
implemented in the mobile agent framework called Maglog [4]. Figure 2 shows an interaction
between agents.

Node Agent (NA): Each node has one node agent. It manages the zone information of a CAN
and forwards messages to the Category Agents in the node.

Exercise Agent (EA): Each Exercise Agent has questions and functions to score user’s
answers, to tell the correct answers, and to show some related information about the exercise.
Category Agent (CA): One category agent is installed in one learning category. A category
agent manages exercise agents related on its category and dispatches the learning request to
them.

User Agent (UA): Each user has its own User Agent. A User Agent manages user’s learning
information that includes login name, password, IP address of the user’s computer,
online/offline status, and log of learning and/or a list of created exercises.

Group Agent (GA): Each group agent manages user agents.

User Interface: One user interface is on each node which a user logs in as a student. It provides
a user interface program for learning.
6.7. Android Multimedia
Android provides many ways to control playback of audio/video files and streams. One of
this way is through a class called MediaPlayer.

Android is providing MediaPlayer class to access built-in mediaplayer services like playing
audio,video e.t.c. In order to use MediaPlayer, we have to call a static Method create() of this
class. This method returns an instance of MediaPlayer class. Its syntax is as follows −

MediaPlayer mediaPlayer = MediaPlayer.create(this, R.raw.song);

The second parameter is the name of the song that you want to play. You have to make a new
folder under your project with name raw and place the music file into it.

Once you have created the Mediaplayer object you can call some methods to start or stop the
music. These methods are listed below.

mediaPlayer.start();

mediaPlayer.pause();

On call to start() method, the music will start playing from the beginning. If this method is
called again after the pause() method, the music would start playing from where it is left and
not from the beginning.

In order to start music from the beginning, you have to call reset() method. Its syntax is given
below.

mediaPlayer.reset();
Apart from the start and pause method, there are other methods provided by this class for
better dealing with audio/video files.

Android framework to implement multimedia capture and playback.

Media Playback

How to play audio and video in your application.

JetPlayer

How to play interactive audio and video in your application using content created with
JetCreator.

Camera

How to use a device camera to take pictures or video in your application.

Audio Capture How to record sound in your application

You might also like