Académique Documents
Professionnel Documents
Culture Documents
Practical: 1
Write a program to simulate Fixed TDM. Take 12 stations. Every station has time slice of
417 microseconds. Delay should be 10ms. Also show the uplink and downlink concept.
#Define different colors for data flows (for NAM) $ns color 1 Blue
$ns color 2 Green
#Schedule events for the CBR and FTP agents $ns at 0.0 "$cbr start"
$ns at 1.0 "$ftp start" $ns at 4.0 "$ftp stop"
$ns at 4.5 "$cbr stop"
#Call the finish procedure after 5 seconds of simulation time $ns at 3.0 "finish"
Output:
Practical: 2
# Define options
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
create-god $val(nn)
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON
# Generation of movements
$ns at 10.0 "$node_(0) setdest 250.0 250.0 3.0"
$ns at 15.0 "$node_(1) setdest 45.0 285.0 5.0"
$ns at 110.0 "$node_(0) setdest 480.0 300.0 5.0"
$ns run
Output:-
Practical: 3
Implement DSDV protocol.
# Define options
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
create-god $val(nn)
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON
# Generation of movements
$ns at 10.0 "$node_(0) setdest 250.0 250.0 3.0"
$ns at 15.0 "$node_(1) setdest 45.0 285.0 5.0"
$ns at 110.0 "$node_(0) setdest 480.0 300.0 5.0"
$ns run
Output:-
Practical: 4
# Define options
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
create-god $val(nn)
#
# Create nn mobilenodes [$val(nn)] and attach them to the channel.
#
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON
# Generation of movements
# $ns at 10.0 "$node_(0) setdest 250.0 250.0 3.0"
# $ns at 15.0 "$node_(1) setdest 45.0 285.0 5.0"
# $ns at 70.0 "$node_(2) setdest 480.0 300.0 5.0"
# $ns at 20.0 "$node_(3) setdest 200.0 200.0 5.0"
# $ns at 25.0 "$node_(4) setdest 50.0 50.0 10.0"
# $ns at 60.0 "$node_(5) setdest 150.0 70.0 2.0"
# $ns at 90.0 "$node_(6) setdest 380.0 150.0 8.0"
# $ns at 42.0 "$node_(7) setdest 200.0 100.0 15.0"
# $ns at 55.0 "$node_(8) setdest 50.0 275.0 5.0"
# $ns at 19.0 "$node_(9) setdest 250.0 250.0 7.0"
# $ns at 90.0 "$node_(10) setdest 150.0 150.0 20.0"
# $ns at 75.0 "$node_(11) setdest 75.0 100.0 5.0"
$ns run
Output:-
Practical: 5
Output:-
Roll No. 1507002009 26 | P a g e
MEFGI Wireless Communication
Practical: 6
Implement an Android application that converts Fahrenheit to Celsius and Celsius to
Fahrenheit.
MyActivity.java
package com.example.sairam.myapplication;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MyActivity extends ActionBarActivity
{
EditText e1,e2;
Button b1;
String str;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
b1=(Button) findViewById(R.id.convert);
e1=(EditText) findViewById(R.id.fahernhit);
e2=(EditText) findViewById(R.id.celsius);
final Float[] num = new Float[1];
b1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
if("".equals(e1.getText().toString()))
{
num[0] = Float.parseFloat(e2.getText().toString());
num[0] = new Float((num[0]*1.8)+32);
str=String.valueOf(num[0]);
e1.setText(str);
}
else if("".equals(e2.getText().toString()))
{
num[0] = Float.parseFloat(e1.getText().toString());
num[0] = new Float((num[0] - 32.0) / 1.8);
str=String.valueOf(num[0]);
e2.setText(str);
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.my, menu);
return true;
}
}
activity_my.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MyActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="29dp"
android:text="Fahernhit"
android:id="@+id/textview1"
android:layout_weight="0.92"
android:autoText="false"
android:textSize="20dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/fahernhit"
android:layout_below="@+id/textview1"
android:layout_alignParentStart="true"
android:layout_alignEnd="@+id/textview1"
android:autoText="false" />
<TextView
android:layout_width="wrap_content"
android:layout_height="29dp"
android:text="Celsius"
android:id="@+id/textView2"
android:layout_below="@+id/fahernhit"
android:layout_alignParentStart="true"
android:layout_alignEnd="@+id/fahernhit"
android:textSize="20dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/celsius"
android:layout_below="@+id/textView2"
android:layout_alignParentStart="true"
android:layout_alignEnd="@+id/textView2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Convert"
android:id="@+id/convert"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
Output:-
Practical: 7
Implement an Android application that takes name as input. It gives radio buttons with
list of subjects. User need to choose 1 subject. Then there are list of books user has to
choose. Then display name, choice of subject and selected subjects.
MyActivity.java
package com.example.sairam.prc2;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
public class MyActivity extends ActionBarActivity {
RadioButton rb;
RadioGroup rg;
Spinner sp1;
EditText e1;
TextView t1;
Button b1;
@Override
@Override
activity_my.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MyActivity"
android:id="@+id/rel1">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/Name"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:hint="Enter Name" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Choose Subject"
android:id="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textSize="20dp"
android:layout_below="@+id/Name"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:id="@+id/radioGroup1"
android:layout_below="@+id/textView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wireless Communication"
android:id="@+id/radioButton1"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android"
android:id="@+id/radioButton2"
android:layout_below="@+id/radioButton1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Java"
android:id="@+id/radioButton3"
android:layout_below="@+id/radioButton2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RadioGroup>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Choose Book"
android:id="@+id/textView2"
android:textSize="20dp"
android:layout_below="@+id/radioGroup1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Spinner
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/Bookname"
android:layout_below="@+id/textView2"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="submit"
android:id="@+id/submit"
android:layout_below="@+id/Bookname"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/disp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/submit"
android:textSize="20dp"
android:visibility="invisible" />
</RelativeLayout>
</ScrollView>
Output :-
Practical: 8
Implement Multiple Row Scrolling Application.
MyActivity.java
package com.example.sairam.practical3;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MyActivity extends ActionBarActivity
{
String[] mobileArray = {"Wireless Communication","Computer Algorithm","Artifical
Inteligence","Research Skill","Numerical Method","Distributed Operating System",
"Data warehousing and Data Mining","Android","Image processing",".NET","Advance Java","Computer
Network","Data File Structure"
};
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.listview_layout, mobileArray);
getMenuInflater().inflate(R.menu.my, menu);
return true;
}
}
activity_my.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MyActivity">
<ListView
android:id="@+id/mobile_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</RelativeLayout>
listview_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Single List Item Design -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
android:textSize="16dip"
android:textStyle="bold" >
</TextView>
Output :-
Practical: 9
Implement an Android Application that creates a menu with following options.
(a)Display menu items for example – List the choice of food items. Display list of selected
items. Calculate the bill.
Activity_Main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:background="@drawable/bg"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.namaskarrestaurent.South_Indian" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Menu"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/button1"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TableRow
android:layout_margin="1dp"
android:id="@+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Items"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Price”
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Quantity”
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
<TableRow
android:layout_margin="1dp"
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18dp"
android:text="Sada Dhosa" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rs.80"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="28dp" />
</TableRow>
<TableRow
android:layout_margin="1dp"
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18dp"
android:text="Masala Dhosa" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rs.100"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="28dp" />
</TableRow>
<TableRow
android:layout_margin="1dp"
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<CheckBox
android:id="@+id/checkBox3”
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18dp"
android:text="Butter Dhosa" />
<TextView
android:id="@+id/textView”
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rs. 120"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/spinner3"
android:layout_width="wrap_content"
android:layout_height="28dp" />
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp" >
<CheckBox
android:id="@+id/checkBox4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18dp"
android:text="Spring Dhosa" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rs. 150"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/spinner4"
android:layout_width="wrap_content"
android:layout_height="22dp" />
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView9"
android:layout_centerHorizontal="true"
android:text="Calculate" />
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_alignParentBottom="true"
android:layout_marginBottom="66dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
Activity_Main.java
package com.example.namaskarrestaurent;
import java.util.ArrayList;
import java.util.List;
import android.R.integer;
import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
public class South_Indian extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_south__indian);
Button b1 = (Button)findViewById(R.id.button1);
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
int i = 0;
if (c1.isChecked()){
i = i+(80 * Integer.parseInt(s1.getSelectedItem().toString()));
}
if (c2.isChecked()){
i = i+(100 * Integer.parseInt(s2.getSelectedItem().toString()));
}
if (c3.isChecked()){
i = i+(120 * Integer.parseInt(s3.getSelectedItem().toString()));
}
if (c4.isChecked()){
i = i+(150 * Integer.parseInt(s4.getSelectedItem().toString()));
}
Intent in = new Intent(South_Indian.this,Namaskar.class);
in.putExtra("Data",String.valueOf(i));
//startActivity(in);
TextView t = (TextView)findViewById(R.id.textView9);
t.setText("Total bill is "+String.valueOf(i));
i = 0;
}
});
}
@Override
Output:-
Practical: 10
Use Table Layout to display the buttons with images on them. When you click on that
image it should be displayed in large area.
Main Activity_multiple.java
package com.example.prac10i;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity_multiple extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_activity_multiple);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_activity_multiple, menu);
return true;
}
}
Main Activity_multiple.xml
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="@+id/tableRow4"
android:layout_weight="1" >
<ImageButton
android:id="@+id/button_one"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
Roll No. 1507002009 55 | P a g e
MEFGI Wireless Communication
android:adjustViewBounds="true"
android:background="@drawable/ic_launcher"
android:scaleType="fitCenter"
android:src="@drawable/ic_launcher" />
<ImageButton
android:id="@+id/button_two"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:adjustViewBounds="true"
android:background="@drawable/ic_launcher"
android:scaleType="fitCenter"
android:src="@drawable/ic_launcher" />
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_weight="1" >
<ImageButton
android:id="@+id/button_three"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:adjustViewBounds="true"
android:background="@drawable/ic_launcher"
android:scaleType="fitCenter"
android:src="@drawable/ic_launcher" />
</TableRow>
</TableLayout>
Output:-
Practical: 11
Create a table with student information. Apply the operations add, modify, delete.
MainActivity.java
package com.example.prac11;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import java.util.ArrayList;
import java.util.List;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity implements OnClickListener{
EditText name, phone_no, id;
Button addButton, deleteButton;
TextView tv;
List<StudentsModel> list = new ArrayList<StudentsModel>();
DatabaseHelper db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
db = new DatabaseHelper(getApplicationContext());
name = (EditText) findViewById(R.id.editText1);
phone_no = (EditText) findViewById(R.id.editText2);
id = (EditText) findViewById(R.id.editText3);
addButton = (Button) findViewById(R.id.add);
deleteButton = (Button) findViewById(R.id.delete);
tv = (TextView) findViewById(R.id.tv);
addButton.setOnClickListener(this);
deleteButton.setOnClickListener(this);
public StudentsModel(){
}
}
DatabaseHelper.java
package com.example.prac11;
import android.content.Context;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
values.put(KEY_PHONENUMBER, student.phone_number);
long insert = db.insert(TABLE_STUDENTS, null, values);
return insert;
}
public int updateEntry(StudentsModel student) {
SQLiteDatabase db = this.getWritableDatabase();
if (c != null)
c.moveToFirst();
return students;
}
public List<StudentsModel> getAllStudentsList() {
List<StudentsModel> studentsArrayList = new ArrayList<StudentsModel>();
SQLiteDatabase db = this.getReadableDatabase();
Cursor c = db.rawQuery(selectQuery, null);
if (c.moveToFirst()) {
do {
StudentsModel students = new StudentsModel();
students.id = c.getInt(c.getColumnIndex(KEY_ID));
students.phone_number =
c.getString(c.getColumnIndex(KEY_PHONENUMBER));
students.name = c.getString(c.getColumnIndex(KEY_NAME));
studentsArrayList.add(students);
}
while (c.moveToNext());
}
return studentsArrayList;
}
}
}
Output:-
Practical: 12
Implement an Android Application that rotates a cube in clockwise direction for 1 minute
and after that cube in the anticlockwise direction.
MainActivity.java
package com.example.prac12;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.Window;
import android.view.WindowManager;
@Override
public void run() {
// TODO Auto-generated method stub
try
{
view.setRenderer(new OpenGLRenderer());
Thread.sleep(10);
finish();
}
catch(Exception e)
{
e.printStackTrace();
}
}
};
try
{
Thread t=new Thread(null,runnable);
t.start();
view.setRenderer(new OpenGLRenderer1());
// Intent i=new Intent(this,OpenGLRenderer.class);
// startActivity(i);
}
catch(Exception e)
{
}
}
}
OpenGLRenderer.java
package com.example.prac12;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLSurfaceView.Renderer;
import android.opengl.GLU;
public class OpenGLRenderer implements Renderer {
private Square square;
private float angle = 0;
public OpenGLRenderer() {
square = new Square();
}
public void onDrawFrame(GL10 gl) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glTranslatef(0, 0, -10);
gl.glPushMatrix();
gl.glRotatef(angle, 0, 0, 1);
square.draw(gl);
. gl.glPopMatrix();
square.draw(gl);
gl.glPopMatrix();
angle++;
}
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL10.GL_PROJECTION);
// Reset the projection matrix
gl.glLoadIdentity();
GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f, 100.0f);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
}
Public void onSurfaceCreated(GL10 gl, EGLConfig config) {
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
gl.glShadeModel(GL10.GL_SMOOTH);
gl.glClearDepthf(1.0f);
gl.glEnable(GL10.GL_DEPTH_TEST);
gl.glDepthFunc(GL10.GL_LEQUAL);
gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST); }
}
Output:-