[Link].
: 1 Develop an android application that displays a text
AIM:
To develop the android mobile application which consist of text view
ALGORITHM:
Step 1: Open the actual project folder in Eclipse IDE.
Step 2: Design the application by inserting edit text, text views and buttons.
Step 3: Type the coding in the MainActivity Page.
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity {
Button b;
EditText e;
TextView t;
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
b=(Button)findViewById([Link].button1);
e=(EditText)findViewById([Link].editText1);
t=(TextView)findViewById([Link].textView1);
[Link](new OnClickListener() {
public void onClick(View arg0) {
String a=[Link]().toString();
[Link](a);
Page | 1
}
});
}
}
Step 4: Run this application in android emulator.
OUTPUT
Page | 2
[Link].: 2 Develop a simple toast application
AIM:
To develop the android mobile application to display the toast message.
ALGORITHM:
Step 1: Open the actual project folder in Eclipse IDE.
Step 2: Design the application by inserting edit text, text views and buttons.
Step 3: Type the coding in the MainActivity Page.
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity {
EditText tt;
Button calculate;
int year;
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
tt=(EditText)findViewById([Link].editText1);
calculate=(Button)findViewById([Link].button1);
[Link](new OnClickListener()
{
public void onClick(View arg0) {
year=[Link]([Link]().toString());
if (year%4==0)
Page | 3
[Link]([Link],"It is a leap year", Toast.LENGTH_LONG).show();
else
[Link]([Link],"It is not a leap year",Toast.LENGTH_LONG).show();
}
});
}
}
Step 4: Run this application in android emulator.
OUTPUT
Page | 4
Develop an android application that uses
[Link].: 3
GUI components, font and colors
AIM:
To develop the android application that uses GUI components, font and colors.
ALGORITHM:
Step 1: Open the actual project folder in Eclipse IDE.
Step 2: Design the application by inserting edit text, text views and buttons.
Step 3: Type the coding in the MainActivity Page.
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity {
int ch=1;
float font=30;
TextView t;
Button b1,b2;
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
t=(TextView)findViewById([Link].textView1);
b1=(Button)findViewById([Link].button1);
b2=(Button)findViewById([Link].button2);
[Link](new OnClickListener()
Page | 5
{
public void onClick(View arg0)
{
[Link](font);
font = font + 5;
if (font == 50)
font = 30;
}
});
[Link](new OnClickListener()
{
public void onClick(View arg0)
{
switch (ch) {
case 1:
[Link]([Link]);
break;
case 2:
[Link]([Link]);
break;
case 3:
[Link]([Link]);
break;
case 4:
[Link]([Link]);
break;
case 5:
[Link]([Link]);
break;
case 6:
[Link]([Link]);
break;
}
ch++;
if (ch == 7)
Page | 6
ch = 1;
}
});
}
}
Step 4: Run this application in android emulator.
OUTPUT
Page | 7
Develop an android application that creates an alert upon
[Link].: 4
receiving a message
AIM:
To develop the android application that creates an alert upon receiving a message.
ALGORITHM:
Step 1: Open the actual project folder in Eclipse IDE.
Step 2: Design the application by inserting edit text, text views and buttons.
Step 3: Type the coding in the MainActivity Page.
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity {
final Context context = this;
Button button;
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
button = (Button) findViewById([Link].button1);
[Link](new OnClickListener() {
public void onClick(View arg0) {
[Link] alertDialogBuilder = new [Link](context);
Page | 8
// set the title of the Alert Dialog
[Link]("Exit Application?");
// set dialog message
alertDialogBuilder
.setMessage("Click yes to exit!")
.setCancelable(false)
.setPositiveButton("Yes",
new [Link]() {
public void onClick(DialogInterface dialog,
int id) {
// if yes is clicked, close
// current activity
[Link]();
}
})
.setNegativeButton("No",
new [Link]() {
public void onClick(DialogInterface dialog,
int id) {
// if no is clicked, just close
// the dialog box and do nothing
[Link]();
}
});
AlertDialog alertDialog = [Link]();
[Link]();
}
});
}
}
Step 4: Run this application in android emulator.
Page | 9
OUTPUT
Page | 10
[Link].: 5 Develop an android application to implement various intents
AIM:
To develop the android mobile application to implement various intents.
ALGORITHM:
Step 1: Open the actual project folder in Eclipse IDE.
Step 2: Design the application by inserting text views and buttons.
Step 3: Type the coding in the Main Activity Page and create a new activity called Page2.
Step 4: Run this application in android emulator.
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity
Button n;
protected void onCreate(Bundle savedInstanceState)
[Link](savedInstanceState);
setContentView([Link].activity_main);
n=(Button)findViewById([Link].button1);
[Link](new OnClickListener()
public void onClick(View arg0)
Page | 11
{
Intent in=new Intent([Link],[Link]);
startActivity(in);
});
Step 4: Run this application in android emulator.
OUTPUT
Page | 12