Soft Copy Format For MCC
Soft Copy Format For MCC
Exp.no: 1
Theory: A wireless local area network (WLAN) links two or more devices using
some wireless distribution method (typically spread spectrum or OFDM radio),
and usually providing a connection through an access point to the wider Internet.
This gives users the mobility to move around within a local coverage area and
still be connected to the network, most modem WLANs are based on IEEE
802.11 standards. Marketed under the WIFI brand name. WLAN s were once
called LAWN s (for local area wireless network) by the Department of Defense.
Wireless LANs have become popular in the home due to case of installation, and
in commercial complexes offering wireless access to their customers: often for
free New York city, for instance, has begun a pilot program to provide city
workers in all five boroughs of the city with wireless Internet access, A WLAN
provides wireless network communication over short distances using radio or
infrared signals instead of traditional network cabling. A WLAN typically
extends an existing wired local area network. WLANs are built by attaching a
device called the access point (AP) to the edge of the wired network. Clients
communicate with the AP using a wireless network adapter similar in function to
a traditional Ethernet adapter, WLAN utilizes the modulation technology based
on radio waves to communicate between devices in a limited network Area
All components that can connect into a wireless medium in a network are
referred to as stations. All stations are equipped with wireless network interface
controllers (WNICs). Wireless stations fall into one of two categories: access
points, and clients. Access points (APs), normally routers. Are base stations for
the wireless network. They transmit and receive radio frequencies for wireless
enabled devices to communicate with. Wireless clients can be mobile devices
such as laptops, personal digital assistants, IP phones and other smartphones, or
fixed devices such as desktops and workstations that are equipped with a wireless
network interface.
An extended service set (ESS) is a set of connected BSSs, Access points in an ESS
are connected by a distribution system. Each ESS has an ID called the SSID which
is a 32-byte (maximum) character string
Distribution system
A distribution system (DS) connects access poms in a DS can be used to increase
network coverage through roaming between extended service set. The concept
of cells, DS can be wired or wireless. Current wireless distribution systems are
mostly based on WDS or MESH protocols, though other systems are in use,
Types of wireless LANs
1. Peer-to-peer
An ad-hoc network (not the same as a WIFI Direct network) is a network where
stations communicate only peer to peer (P2P). There is no base and no one gives
permission to talk. This is accomplished using the Independent Basic Service Set
(IBSS). network
2. Bridge
A bridge can be used to connect networks, typically of different types. A wireless
Ethernet bridge allows the connection of devices on a wired Ethernet network to
a
wireless network. The bridge acts as the connection point to the Wireless LAN.
A wireless bridge is a hardware component used to connect two or more network
segments (LANs or parts of a LAN) which are physically and logically (by protocol)
wireless to cable. So, in a sense the computer acts as a bridge by using bridging
OS
software.
Ad-hoc Networks
People can access the network from where they want; they are no Longer
limited by the length of the cable.
Some cities have started to offer Wireless LANs. This means that people can
access the Internet even outside their normal work environment, for
example when they ride the train home.
Setting up a wireless LAN can be done with one box (called Access point).
This box can handle a varying number of connections at the same time.
Wired networks require cables to be laid. This can be difficult for certain
places.
Access points can serve a varying number of computers.
Applications
Wireless LANs have a great deal of applications. Modem implementations of
WLANs range from small in-home networks to large, campus-sized ones to
completely mobile networks on airplanes and trains. Users can access the
Internet from WLAN hotspots in restaurants, hotels, and now with portable
devicesthatconnectto3Gor4Gnetworks. Often times these types of public
access points require no registration or password to join the network. Others
can be accessed once registration has occurred and/or a fee is paid.
Conclusion
Wireless LAN provides high speed data communication. Because of their
limited mobility and short transmission range, wireless LANs can be used in
confined areas such as a conference room.
Exp.no: 2
Aim: To study of Bluetooth architecture, Bluetooth protocol and application.
Objective: Different protocols and applications of Bluetooth.
Requirement: Dual-core 1.8 GHz. 4 gig RAM, 10 gig disk space. Windows 7/8
Theory:
What is Bluetooth?
The name Bluetooth comes from the nickname of the Danish King Harald Blat
land. it is a low cost, low power radio communication technology using the
2.4GHz Industrial-Scientific-Medical unlicensed frequency band. It shares this in
common with IEEE802.11 Wi-Fi local area network technology but whereas
IEEE802.11 has a range of 100 meters and a speed of 11 Mb/sec, Bluetooth has a
range of 10 meters and a speed of 1M-bits' sec, However, depending on the
power consumption of the device, Bluetooth range can vary from 1 meter up to
100 meters and version 2 with enhanced data rate (EDR) can operate up to 3.
Mb/sec. It’s used principally to inter connect small hand held devices and other
electronic equipment, high might otherwise use infrared communication. The
major benefit being that it does not require line of sight and can be used to form
small ad-hoc networks of devices. Bluetooth supports a single connectionless data
channel of 789Kbits/sec and up to three synchronous PCMA encoded voice
channels.
Piconets and scatter nets.
Bluetooth enabled devices can be in either a master or slave mode. A group of
devices in which one is designated master and the rest are slaves forms a network
called a piconet. A device can be a slave in several piconets at the same time. A
device can also be a slave in-one piconet and a master in another. This forms a
topology called a scatter Security
The radio layer of Bluetooth performs frequency hopping at the rate of 1600
hop’s to make eavesdropping difficult.
Bluetooth architecture
Bluetooth protocol stack
The Bluetooth protocol stack is split into three layers (radio, baseband, LMP)
implemented in hardware and three layers (HCI, LZCAP and TCS/SDP RFCOMM)
implemented in software. Application code then sits on top of this: -
The various layers functionality is as follows: -
Radio layer-
The physical wireless connection. Uses frequency range 2.4GHz to 2.48GHz split
into 79 channels and performs fast frequency hopping (1600 hops sec) for
security.
Baseband layer –
provides up to 3 synchronous voice channels and one connectionless data
channel. Channels are division multiplexed and spare timeslots (not used by voice
channels) are used for asynchronous data communications. If a master device
transmits in one time slot, unless the message is broadcast. Only the addressed
slave may transmit a reply in the following timeslot.
Link manager protocol (LMP) –
responsible for establishing and maintaining connections in Pico nets as well as
quality motoring and security services.
Host controller interface (HCI) –
this is the interface between the software part of the system and the hardware
(i.e. the device driver}.
14.Short range transmission of health sensor data from medical devices to mobile
phone. set- top box or dedicated telepathy devices.
15. Allowing a DECT phone to ring and answer calls on behalf of a nearby mobile
phone.
16. Real-time location systems (RTLS), are used to track and identify the location
of objects in real-time using “Nodes” or “tags” attached to, or embedded in the
objects tracked, and “Readers” that receive and process the wireless signals from
these tags to determine their locations.
17. Personal security application on mobile phones for prevention of theft or loss
of items. The protected item has a Bluetooth marker (e.g. a tag) that is in constant
communication with the phone. If the connection is broken (the marker is out of
range of the phone) then an alarm is raised. This can also be used as a man
overboard alarm. A product using this technology has been available since 2009.
Exp.no: 3
Aim: To study GSM Security algorithm (A3, A5, A8).
Objective: study GSM Security algorithm (A3, A5, A8).
Requirement: Dual-core 1.8 GHz. 4 gig RAM, 10 gig disk space. Windows 7/8
Theory:
Customers;
Security mechanisms;
A3 Algorithm:
It provides authentication to the user that it has privilege to access the system.
The network authenticates the subscriber through the use of a challenge-
response method. Firstly, a 128-bit random number (RAND) is transmitted to the
mobile station over the air interface. The RAND is passed to the SIM card, where
it is sent through the A3 authentication algorithm together with the KI. The
output of the A3 algorithm, the signed response (SRES) is transmitted via the air
interface from the mobile station back to the network. On the network, the AuC
compares its value of SRES with the value of SRES it has received from the mobile
station. If the two values of SRES match, authentication is successful and the
subscriber joins the network. The AuC actually doesn’t store a copy of SRES but
queries the HLR or the VLR for it, as needed.
A8 Algorithm:
GSM makes use of a ciphering key to protect both user data and
signaling on the vulnerable air interface. Once the user is
authenticated, the RAND (delivered from the network) together with
the Ki (from the SIM) is sent through the A8 ciphering key generating
algorithm, to produce a ciphering key (Kc). The A8 algorithm is stored
on the SIM card. The Kc created by the A8 algorithm, is then used with
the A5 ciphering algorithm to encipher or decipher the data. The A5
algorithm is implemented in the hardware of the mobile phone, as it
has to encrypt and decrypt data on the air. [3] Whenever the A3
algorithm runs to generate SRES, the A8 algorithm is run as well The A8
algorithm uses the RAND and Ki as input to generate a 64-bit ciphering
key, the Kc, which is then stored in the SIM and readable by the phone.
The network also generates the Kc and distributes it to the base station
(BTS) handling the connection.
A5 Algorithm
A5 is a stream cipher which can be implemented very efficiently on hardware.
There exist several implementations of this algorithm, the most commonly used
ones are A5/0, A5/1 and A5/2 (A5/3 is used in 3G systems). The reason for the
different implementations is due to export restrictions of encryption technologies.
A5/1 is the strongest version and is used widely in Western Europe and America,
while the A5/2 is commonly used in Asia. Countries under UN Sanctions and
certain third world countries use the A5/0, which comes with no encryption. [3,
14] As a stream cipher, A5 works on a bit by bit basis (and not on blocks, as DES
and AES). So, an error in the received cipher text will only result in the
corresponding plaintext bit being in error. None of the algorithms are published
EXPERIMENT NO.4
moving across the service area. It can refer an immobile device that stays
connected to one tower, but this is not the meaning of “mobile” here. Wi-Fi and
other better methods are commonly available for users not on the move. Cellular
base stations are more expensive to provide than a wireless base station that
connects directly to an internet service provider, rather than through the
telephone system.
A mobile phone. Such as a smart phone, that connects to data or voice services
with outcome through the cellular base station is not on mobile Internet. A laptop
with a broadband modem and a cellular service provider subscription, that 1s
traveling on a bus through the city is on mobile Internet.
A mobile broadband modem “tethers” the smartphone to one or more computers
or other end user devices to provide access to the Internet via the protocols that
cellular telephone service providers may offer.
It's the ability to access the internet on your mobile phone. That feature has been
on mobiles for a few years now but pages always took a long time to load because
internet speeds on mobiles were quite slow. Mobile technology has caught up
and if you see a mobile advertised as 3G (third generation) it means that it's
capable of much faster web-browsing. What does that mean for you? Fast and
easy access to thousands of websites! Whenever you use the internet on your
phone, you're using data.
Whether it’s browsing the web, sending an email, or watching a TV programmed.
Downloading and using apps will also take a slice out of your data allowance.
to a mobile network or other wireless network
Conclusion: Thus, we have studied about Mobile Internet and WML in detail
characteristics and its advantages.
EXPERIMENT NO.5
AIM: To study of Hidden station problem and how RTS/CTS helps in wireless
network.
Objective: Hidden station problem and how RTS/CTS helps in wireless network.
Requirement: Dual-core 1.8 GHz, 4 gig RAM, 10 gig disk space, Windows 7/8, java
SE 7.
Theory:
Hidden Terminal Problem and the Exposed Terminal Problem are the two
of the main problems occur in wireless networking. This article will discuss
how those problems occur and how to solve those using
the RTS/CTS mechanism.
The hidden terminal problem occurs when a node is visible from an Access
Point and not visible to other nodes which communicate with that Access
Point.
As in the above diagram Access Point B lies within the ranges of both node A
and node C. Node A can directly communicate with Access Point B but not
with node C, similarly, node C can directly communicate with Access Point
B but not with node A. So it is said that the node A is hidden from node
C.
When node A and node C simultaneously send data to node B it will lead to
a collision.
Since node A and C are hidden from each other, both of them will sense the
medium free before sending the data, and will not detect any collision while
sending data. As a result, B will receive corrupted data. This is known as the
hidden terminal problem
Solutions:
1. Increasing the transmission power (range) of the terminals
2. Remove obstacles
3. Move nodes
4. Protocol enhancements
RTS/CTS mechanism to resolve the hidden terminal problem
RTS/CTS is the mechanism used by the 802.11 wireless networking protocol
to resolve the hidden terminal problem. It uses two frames known as RTS
and CTS to check medium for collision avoidance.
RTS — Ready To Send
CTS — Clear To Send
When a node wants to send data, it will first send the RTS signal. If the
Access Point is ready to receive the data (if it is not communicating with any
other node) it will send back the CTS signal. It is a little bit confusing to
understand, but you will get a clear understanding from the following
diagram.
Node B is not in the Node A’s range so it doesn’t receive the first RTS, but
since it is in the range of Access Point, it receives the CT. When a node
receives a CTS signal from an Access Point without a RTS signal, it will
understand that CTS signal is for a hidden terminal, so it will not transfer
the data.
Conclusion: Thus, we have studied Hidden station problem and how RTS/CTS
helps in wireless network.
EXPERIMENT NO.6
AIM: To understand the cellular frequency reuse concept to find the co-channel
cells for a particular cell. Design a game based application on the above concept.
Objective: understand the cellular frequency reuse concept to find the co-channel
cells for a particular cell. Design a game based application on the above concept..
Requirement: Dual-core 1.8 GHz, 4 gig RAM, 10 gig disk space, Windows 7/8,
python-3
Theory:
Frequency Reuse is the scheme in which allocation and reuse of channels
throughout a coverage region is done. Each cellular base station is allocated a group
of radio channels or Frequency sub-bands to be used within a small geographic area
known as a cell.
The shape of the cell is Hexagonal. The process of selecting and allocating the
frequency sub-bands for all of the cellular base station within a system is
called Frequency reuse or Frequency Planning.
Code:
#!/usr/bin/python
start_x = self.x
start_y = self.y
angle = 60
coords = []
for i in range(6):
end_x = start_x + self.length * cos(radians(angle * i))
end_y = start_y + self.length * sin(radians(angle * i))
coords.append([start_x, start_y])
start_x = end_x
start_y = end_y
self.parent.create_polygon(coords[0][0],
coords[0][1],
coords[1][0],
coords[1][1],
coords[2][0],
coords[2][1],
coords[3][0],
coords[3][1],
coords[4][0],
coords[4][1],
coords[5][0],
coords[5][1],
fill=self.color,
outline="black",
tags=self.tags)
self.reuse_xy = []
self.canvas = Canvas(self,
width=self.CANVAS_WIDTH,
height=self.CANVAS_HEIGHT,
bg="#4dd0e1")
self.canvas.bind("<Button-1>", self.call_back)
self.canvas.focus_set()
self.canvas.bind('<Shift-R>', self.resets)
self.canvas.pack()
self.title("Frequency reuse and co-channel selection")
self.create_grid(16, 10)
self.create_textbox()
self.cluster_reuse_calc()
end_xx = (self.co_cell_endp[k])[0]
end_yy = (self.co_cell_endp[k])[1]
def create_textbox(self):
txt = Text(self.canvas,
width=80,
height=1,
font=("Helvatica", 12),
padx=10,
pady=10)
txt.tag_configure("center", justify="center")
txt.insert("1.0", "Select a Hexagon")
txt.tag_add("center", "1.0", "end")
self.canvas.create_window((0, 600), anchor='w', window=txt)
txt.config(state=DISABLED)
self.textbox = txt
try:
self.line_ids
except AttributeError:
pass
else:
for i in self.line_ids:
self.canvas.after(0, self.canvas.delete, i)
self.line_ids = []
if button_reset:
self.write_text("Select a Hexagon")
if self.first_click:
self.first_click = False
self.write_text(
"""Now, select another hexagon such
that it should be a co-cell of
the original hexagon."""
)
self.co_cell_endp.append(approx_center)
self.canvas.itemconfigure(hexagon.tags, fill="green")
for _ in range(6):
radians(self.curr_angle - 60))
reuse_y = end_yy + (self.center_dist * j) * sin(
radians(self.curr_angle - 60))
if j == 0:
self.reuse_list.append(
self.canvas.find_closest(end_xx, end_yy)[0])
elif i >= j and j != 0:
self.reuse_list.append(
self.canvas.find_closest(reuse_x, reuse_y)
[0])
self.co_cell_endp.append((end_xx, end_yy))
self.curr_angle -= 60
else:
curr = self.canvas.find_closest(s_x, s_y)[0]
if curr in self.reuse_list:
self.canvas.itemconfigure(hexagon.tags, fill="green")
self.write_text("Correct! Cell {} is a co-cell.".format(
hexagon.tags))
if self.curr_count == len(self.reuse_list) - 1:
self.write_text("Great! Press Shift-R to restart")
self.show_lines()
self.curr_count += 1
else:
self.write_text("Incorrect! Cell {} is not a co-
cell.".format(
hexagon.tags))
self.canvas.itemconfigure(hexagon.tags, fill="red")
if __name__ == '__main__':
print(
"""Enter i & j values. common (i,j) values are:
(1,0), (1,1), (2,0), (2,1), (3,0), (2,2)"""
)
i = int(input("Enter i: "))
j = int(input("Enter j: "))
if i == 0 and j == 0:
raise ValueError("i & j both cannot be zero")
elif j > i:
output:
EXPERIMENT NO.7
AIM: Develop an application that uses GUI components, Font and Colors.
Requirement: Dual-core 1.8 GHz, 4 gig RAM, 10 gig disk space, Windows 7/8, java
SE 7, android studios
Code:
XML File:
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Change font size"
android:textSize="20sp" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Change color"
android:textSize="20sp" />
</LinearLayout>
Java File:
package com.example.exp1;
import android.app.Activity;
import android.graphics.*;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity
{
float font =24;
int i=1;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView t1=(TextView)
findViewById(R.id.textView1);
Button b1 = (Button) findViewById(R.id.button1);
b1.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view)
{
t1.setTextSize(font);
font=font+4;
if(font==40)
font=20;
}
});
Button b2 = (Button) findViewById(R.id.button2);
b2.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view)
{
switch(i)
{
case 1:
t1.setTextColor(Color.parseColor("#0000FF"));
break;
case 2:
t1.setTextColor(Color.parseColor("#00FF00"));
break;
case 3:
t1.setTextColor(Color.parseColor("#FF0000"));
break;
case 4:
t1.setTextColor(Color.parseColor("#800000"));
break;
}
i++;
if(i==5)
i=1;
}
});
}
}
Output:
EXPERIMENT NO.8
<EditText
android:id="@+id/edittext"
android:layout_width="454dp"
android:layout_height="66dp"
android:importantForAutofill="no"
android:inputType="number"
tools:ignore="LabelFor" />
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/button4"
android:layout_below="@+id/edittext"
android:layout_marginTop="94dp"
android:text="@string/but1" />
<Button
android:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/button1"
android:layout_toStartOf="@+id/button3"
android:text="@string/but2" />
<Button
android:id="@+id/button3"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/button2"
android:layout_centerHorizontal="true"
android:text="@string/but3" />
<Button
android:id="@+id/button4"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button1"
android:layout_toStartOf="@+id/button2"
android:text="@string/but4" />
<Button
android:id="@+id/button5"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button4"
android:layout_alignStart="@+id/button2"
android:text="@string/but5" />
<Button
android:id="@+id/button6"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/button3"
android:layout_below="@+id/button3"
android:text="@string/but6" />
<Button
android:id="@+id/button7"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button4"
android:layout_toStartOf="@+id/button2"
android:text="@string/but7" />
<Button
android:id="@+id/button8"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/button5"
android:layout_below="@+id/button5"
android:text="@string/but8" />
<Button
android:id="@+id/button9"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/button6"
android:layout_below="@+id/button6"
android:text="@string/but9" />
<Button
android:id="@+id/button10"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button7"
android:layout_toStartOf="@id/button11"
android:text="@string/dot" />
<Button
android:id="@+id/button11"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button8"
android:layout_alignEnd="@id/button5"
android:text="@string/zero" />
<Button
android:id="@+id/button12"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button9"
android:layout_alignEnd="@id/button9"
android:text="@string/ac" />
<Button
android:id="@+id/add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="160dp"
android:layout_toEndOf="@id/button3"
android:text="@string/add" />
<Button
android:id="@+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/add"
android:layout_toEndOf="@id/button6"
android:text="@string/sub" />
<Button
android:id="@+id/mul"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/sub"
android:layout_toEndOf="@id/button9"
android:text="@string/mul" />
<Button
android:id="@+id/div"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button7"
android:layout_toEndOf="@id/button12"
android:text="@string/div" />
<Button
android:id="@+id/equal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button12"
android:layout_alignEnd="@id/div"
android:layout_alignStart="@id/button10"
android:layout_marginTop="6dp"
android:text="@string/equal" />
</RelativeLayout>
Output:
Expno.: 9
AIM: Write an application that draws basic graphical primitives on the screen.
Requirement: Dual-core 1.8 GHz, 4 gig RAM, 10 gig disk space, Windows 7/8, java
SE 7, android studios.
Code:
Code for Activity_main.xml:
Code for MainActivity.java:
package com.example.exno4;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.widget.ImageView;
public class MainActivity extends Activity { @Override public void
onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); //Creating a Bitmap
Bitmap bg = Bitmap.createBitmap(720, 1280, Bitmap.Config.ARGB_8888);
//Setting the Bitmap as background for the ImageView
ImageView i = (ImageView) findViewById(R.id.imageView);
i.setBackgroundDrawable(new BitmapDrawable(bg));
//Creating the Canvas Object Canvas canvas = new Canvas(bg); //Creating the
Paint Object and set its color & TextSize Paint
paint = new Paint();
paint.setColor(Color.BLUE); paint.setTextSize(50); //To draw a Rectangle
canvas.drawText("Rectangle", 420, 150, paint);
canvas.drawRect(400, 200, 650, 700, paint); //To draw a Circle
canvas.drawText("Circle", 120, 150, paint);
canvas.drawCircle(200, 350, 150, paint); //To draw a Square
canvas.drawText("Square", 120, 800, paint);
canvas.drawRect(50, 850, 350, 1150, paint); //To draw a Line
canvas.drawText("Line", 480, 800, paint);
canvas.drawLine(520, 850, 520, 1150, paint); }
}
Output:
Expno.: 10
AIM: Android Application that implements Multi-threading concept.
Requirement: Dual-core 1.8 GHz, 4 gig RAM, 10 gig disk space, Windows 7/8, java
SE 7, android studios.
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_margin="50dp"
android:layout_gravity="center" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_gravity="center"
android:text="Load Image 1" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_gravity="center"
android:text="Load image 2" />
</LinearLayout>
package com.example.exno7;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity
{
ImageView img;
Button bt1,bt2;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bt1 = (Button)findViewById(R.id.button);
bt2= (Button) findViewById(R.id.button2);
img = (ImageView)findViewById(R.id.imageView);
bt1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
new Thread(new Runnable()
{
@Override
public void run()
{
img.post(new Runnable()
{
@Override
public void run()
{
img.setImageResource(R.drawable.india1);
}
});
}
}).start();
}
});
bt2.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
new Thread(new Runnable()
{
@Override
public void run()
{
img.post(new Runnable()
{
@Override
public void run()
{
img.setImageResource(R.drawable.india2);
}
});
}
}).start();
}
});
}
}
Output: