SlideShare una empresa de Scribd logo
1 de 6
Descargar para leer sin conexión
ðô Å›G¬ôèO™ ðò÷£˜èÀ‚° îèõ™
è¬÷ ªîKMŠð Notification º¬ø
ðò¡ð´Aø¶. «ï£†®çH«èê¬ù Í¡Á
º¬øèO™ ݇†ó£Œ®™ à¼õ£‚è º®»‹.
1. «ì£v† «ï£†®çH«èê¡ (Toast Notifi
cation) 2. v«ì†ìv 𣘠«ï£†®çH«èê¡
(Status Bar Notification) 3. ìòô£‚ «ï£†®
çH«èê¡ (Dialog Notification)
«ì£v†
«ï£†®çH«èê¡
(Toast Notification)
«ì£v† «ï£†®
çH«èê¡ ðò¡ð£†
®™ àœ÷ F¬óJ™
«î£¡Á‹. ªð¼‹ð£
½‹ å¼ ªêò™ ï¬ì
ªðŸÁœ÷¶ â¡
ðî¬ù ðòù£÷˜
èÀ‚° ªîKMŠð
«ì£v† ðò¡ð´A
ø¶. ꣡ø£è Üô£˜‹
«ïóˆF¬ù ñ£ŸPò
¾ì¡ «ïó‹ ñ£P»œ÷¶ â¡ðî¬ùˆ ªîK
MŠð‹, îèõ™
«ì†ì£«ðC™ «êI‚
èŠð´œ÷¶ â¡ð
î¬ùˆ ªîKMŠðîŸ
°‹ ðò¡ð´Aø¶.
v«ì†ìv ð£˜
«ï£†®çH«èê¡
(Status Bar Notifica-
tion)
v«ì†ìv ð£˜
«ï£†®H«èê¡ÜŠO
«èê¡ «ñ™ð°FJ™
«î£¡Á‹. ꣡ø£è,
âvâ‹âv õ‰¶œ÷¶ â¡ð¬î ªîKMˆ¶
܉î îèõ¬ô «î˜‰ªî´ˆî£™ âvâ‹âv
J¬ù ð®‚èô£‹. ¹Fò ÜŠO«èê¡ GÁ¾Al˜
èœ, GÁMò¾ì¡
v«ì†ìv«ï£†®
H«èê¡ Íô‹ GÁ¾
î™ º®‰¶ M†ì¶
â¡ðî¬ù ªîKòŠ
ð´ˆîô£‹. ܉î
v«ì†ìv 𣘠«ï£†®H«èê¬ù AO‚
ªêŒ¶ 𣘈 ðòù£÷¼‚° â¡ù ï¬ì
ªðŸÁœ÷¶ â¡ø îèõ™ «î£¡Áñ£Á
à¼õ£‚°õ v«ì†ìv 𣘠«ï£†®
H«èê¡ ðò¡ð´ Aø¶.
îèõ™ ªîKM‚°‹ º¬ø
ìòô£‚ «ï£†®çH«èê¡ (Dialog Notification)
ªêò™ð†´ ªè£‡®¼‚°‹ Ý‚®M†
®‚° (Activity) «ñ«ô îèõ¬ôˆ ªîKMˆ¶,
H¡ù˜ ܉î F¬óJ™ «î˜‰ªî´‚°‹ àœ
k†®Ÿ° ãŸð ªêò™è¬÷ ñ£ŸP ܬñ‚è
ìòô£è «ï£†®çH«èê¡ ðò¡ð´Aø¶. ꣡
ø£è å¼ F¬óJL¼‰¶ ñŸªø£¼ F¬ó‚°
ªê™õ ðòù£÷¼‚° æ.«è. ñŸÁ‹ «è¡ê™
â¡ø «î˜M¬ù ÜOˆ¶, æ.«è. ªè£´ˆî£™
Ü´ˆî F¬ó‚° ªê™ô «õ‡´‹, «è¡ê™
ªè£´ˆî£™ Ü«î F¬óJ™ Þ¼‚è «õ‡´‹
«ð£¡ø ªêò™ð£†®¬ù à¼õ£‚è ìòô£‚
«ï£†®çH«èê¡ ðò¡ð´Aø¶.
«ì£v† «ï£†®çH«èê¬ù ݇†ó£Œ´
ÜŠO‚«èêQ™ ðò¡ð´ˆ¶õ «ì£v†
ÝŠªü‚† ðò¡ð´Aø¶. îèõ™è¬÷ F¬ó
J™ 裇ð makeText() ªñˆî®Ÿ° Í¡Á
Mîñ£ù îèõ™è¬÷ ªè£´‚è «õ‡´‹.
ܬõ â‰î F¬ó, â¡ù îèõ™ ñŸÁ‹ âš
õ÷¾ «ïó‹ â¡ðùõŸ¬ø ªè£´‚è «õ‡
´‹. «ì£v†®¬ù ÜŠO‚«èêQ™ 裇
HŠð show() ªñˆî† ðò¡ð´Aø¶. ꣡
ø£è, (Gó™-1)
ðì‹-1
ðì‹-2
ðì‹-3
Gó™-1
Gó™-2
Gó™-3
Toast F¬óJ¡ â‰îŠ ð°FJ™ «î£¡ø
«õ‡´‹ â¡ðî¬ù °PŠð setGravity()
ªñˆî† ðò¡ð´Aø¶.
꣡ø£è,
toast.setGravity(Gravity.Top,o,o,);
Ü™ô¶
toast.setGravity(Gravity.LEFT,O,O);
Ü´ˆ¶ «ï£†®çH«èê¬ù, v«ì†ìú
ð£K™ à¼õ£‚°‹ º¬øJ¬ù 𣘊«ð£‹.
¹Fò Šó£ªü‚† å¡P¬ù à¼õ£‚°«õ£‹.
Project Name â¡ðî¬ù Notification Manager
âù ¬õˆ¶‚ ªè£œ«õ£‹. Ý‚®M†®
ªðòK¬ù Create Notification âùŠ ªðòK´
«õ£‹. ÜF™ mail.xml -Ÿè£ù «è£´ (code)
Gó™ 2-™ ªè£´‚èŠð†´œ÷¶. Ü´ˆîî£è
result.xml â¡ø ç¬ðL¬ù Gó™ 3-™ àœ÷¶
«ð£¡Á à¼õ£‚è «õ‡´‹. result.xml ‚è£ù
Activity Notification Receiver â¡ð‹. ÜF™
Ý¡†ó£Œ´ -2
Þ󣋰ñ£˜ ªô†²Iï£ó£òí¡
06
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class CreateNotification extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void createNotification(View view) {
NotificationManager
notificationManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
Notification notification = new
Notification(R.drawable.icon,
"A new notification",
System.currentTimeMillis());
// Hide the notification after its selected
notification.flags |=
Notification.FLAG_AUTO_CANCEL;
Intent intent = new Intent(this,
NotificationReceiver.class);
PendingIntent activity =
PendingIntent.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(this, "This is the
title",
"This is the text", activity);
notification.number += 1;
notificationManager.notify(0,
notification);
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/
apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button1"
android:text="@string/btn_name"></Button>
</LinearLayout>
Gó™-4
Gó™-5
Gó™-6
package com.ram.dialogex;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
public class DialogExActivity extends Activity {
/** Called when the activity is first created.
*/
Button b1;
@Override
public void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b1 = (Button)findViewById(R.id.button1);
b1.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
AlertDialog alertDialog = new
AlertDialog.Builder(DialogExActivity.this).creat
e();
alertDialog.setTitle("Reset...");
alertDialog.setMessage("R u sure?");
alertDialog.setIcon(R.drawable.icon);
alertDialog.setButton("OK", new
DialogInterface.OnClickListener() {
public void
onClick(DialogInterface dialog, int which) {
//here you can add functions
} });
alertDialog.show();
}
})
;
}
}
ðì‹-4
ðì‹-5
Gó™-7
Gó™-8
Gó™ A™ àœ÷¶ «ð£¡ø Š«ó£Aó£
I¬ù à¼õ£‚è «õ‡´‹. Þ‰î ç¬ðL™
result.xml notificationmanager Activity -»ì¡
SetContentView(R.layout.result) â¡ø õKJ¡
Íô‹ ެ특 ãŸð´ˆF»œ«÷£‹. Ü´ˆ¶
CreateNotifoca
t i o n- Ÿ è £ ù
Gó¬ô à¼õ£
‚è «õ‡´‹.
«ï£†®çH«è
êQ¬ù Þ‰î
꣡P™ CreateNotification â¡ø ªð£ˆî£¬ù‚
AO‚ ªêŒî¾ì¡ ªêò™ ï¬ìªðÁõ
main.xml ç¬ðL™ «ï£†®çH«èê¡ «ñ«ù
ü¬ó ðò¡ð´ˆî «õ‡´‹. CreateNotification
-Ÿè£ù Gó™ ä‰F™ ªè£´‚èŠð†´œ÷¶.
ÜŠO‚«èê¬ù ªêò™ð´ˆ¶õ º¡
sAndroidManifest.xml ç¬ðL™ W›‚è‡ì õK
è¬÷ Þ¬í‚è «õ‡´‹.
ÜŠO«èê¬ù„ ªêò™ð´ˆ¶õ sRun
As -> Andriod Application â¡Á ªè£´‚è «õ‡
´‹.
F¬óJ™ «î£¡Á‹ Create Notification
â¡ø ªð£ˆî£¬ù‚ AO‚ ªêŒî£™ «ï£†®
çH«èê¡ v«ì†ìv 𣘠«î£¡Á‹.
Ü´ˆîî£è ìòô£‚ «ï£†®çH«èêQŸ
è£ù ꣡Á à¼õ£‚°‹ º¬ø¬òŠ 𣘊
«ð£‹.
Dialog Notification Dialog A÷£R¬ù
Ü®Šð¬ìò£è‚ ªè£‡´ à¼õ£‚èŠð´Aø¶.
ìòô£‚ A÷£C¬ù Ü®Šð¬ìò£è ªè£‡´
Alert Dialog, Progress Dialog, DatePickerDialog,
TimePickerDialog «ð£¡ø¬õ àœ÷ù. Ý‚®
M†®J¬ùÜ®Šð¬ìò£èªè£‡«ììòô£‚
package com.ram.datepickerexample;
import android.app.Activity;
import java.util.Calendar;
import android.app.DatePickerDialog;
import android.widget.DatePicker;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class DatePickerExampleActivity
extends Activity {
private TextView mDateDisplay;
private int mYear;
private int mMonth;
private int mDay;
static final int DATE_DIALOG_ID = 1;
@Override
protected void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mDateDisplay = (TextView)
findViewById(R.id.dateDisplay);
Button pickDate = (Button)
findViewById(R.id.pickDate);
pickDate.setOnClickListener(new
View.OnClickListener() {
public void onClick(View v) {
showDialog(DATE_DIALOG_ID);
}
});
final Calendar c =
Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay =
c.get(Calendar.DAY_OF_MONTH);
updateDisplay();
}
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
return new
DatePickerDialog(this,
mDateSetListener,
mYear, mMonth, mDay);
}
return null;
}
protected void onPrepareDialog(int id,
Dialog dialog) {
switch (id) {
case DATE_DIALOG_ID:
((DatePickerDialog)
dialog).updateDate(mYear, mMonth, mDay);
break;
}
}
private void updateDisplay() {
mDateDisplay.setText(
new StringBuilder()
// Month is 0 based so add 1
.append(mMonth + 1).append("-
")
.append(mDay).append("-")
.append(mYear).append(" "));
}
private DatePickerDialog.OnDateSetListener
mDateSetListener =
new
DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker
view, int year, int monthOfYear,
int dayOfMonth) {
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
updateDisplay();
}
};
}
ðì‹-6
Gó™-9
à¼õ£‚èŠð´‹. Ý‚®M†®JL¼‰¶ ìòô£‚
à¼õ£‚°õ OnCreateDialog(int) â¡ø
ªñˆî† ðò¡ð´Aø¶.
Üô£˜† ìòô£‚ ªêòL¬ù ÜP‰¶ ªè£œ
õ ¹Fò Šó£ªü‚† Ýè Dialog Ex â¡
ðî¬ù à¼õ£‚°«õ£‹. ÞF™ Button å¡P¬ù
à¼õ£‚A Üî¬ù AO‚ ªêŒî£™ Üô£˜†
ìòô£‚ «î£¡Á‹. ÞîŸè£ù «ôܾ† ç¬ð™
main.xml Ý°‹. (Gó™ 6)
main.xml L™ à¼õ£‚A
àœ÷ ªð£ˆî£Q¡ ªðò˜
Button 1 â¡ð‹. ªð£ˆ
ù DialogExActivity -J™
ެ특 ãŸð´ˆî ºîL™ ªð£ˆî£¡
ÝŠªü‚®¬ù à¼õ£‚è «õ‡´‹.
Button b1 ;
H¡¹
b1 = (Button) findViewById(R.id.button1);
â¡Á ðò¡ð´ˆî «õ‡´‹.
ªð£ˆî£¬ù‚ AO‚ ªêŒî£™ ªêò™
ï¬ìªðÁõ b1. SetOnClickListener();
â¡ðî¬ù ðò¡ð´ˆî «õ‡´‹.
Üô£˜†ìòô£‚A¬ùà¼õ£‚°
õ Alert.Dialog.Builder ðò¡
ð´Aø¶.
- ªî£ì¼‹
ðì‹-7
AlertDialog alertdialog=new AlertDialog.
Builder(DialogExActivity.this).create Ý°‹.
Üô£˜† ìòô£‚ ªêò™ð£†®Ÿè£ù Gó™
7-™ ªè£´‚èŠð†´œ÷¶. ÜîŸè£ù F¬ó
ðì‹ 5-™ àœ÷¶ «ð£¡Á «î£¡Á‹.
Ü´ˆîî£è Progress Dialog ðò¡ð´ˆ¶‹
º¬øJ¬ù 𣘊«ð£‹. ꣡ø£è,
ProgressDialog dialog = progressDialog.show(
DialogExActivity.this,"",
"Please Wait for few Seconds...",true);
Progress Dialog -J¬ù GÁˆ¶õîŸè£ù
ðò¡ð£´.
ProgressDialogName.dismiss();
 ðò¡ð´ˆF àœ÷ ꣡P™ dialog.
dismiss(),; â¡Á ðò¡ð´ˆî «õ‡´‹.
Progress Dialog ÜŠO‚«èêQ™F¬ó 6-™
àœ÷¶ «ð£¡Á «î£¡Á‹.
Date Picker Dialog -J¬ù à¼õ£‚è main.
xml ç¬ðL¬ù «ôܾ† Ýè ܬñˆ¶ Text
View ñŸÁ‹ Button Þ¼‚°ñ£Á à¼õ£‚è
«õ‡´‹. ð†ìQ¬ù‚ AO‚ ªêŒî£™ Date
Picker Dialog «î£¡Áñ£Á Date Picker
Example Activity -J¬ù à¼õ£‚è «õ‡´‹.
DatePickerExampleActivity.java â¡ø Class
ç¬ðL™ Cô Member è¬÷ Þ¬í‚è
«õ‡´‹. ܬõ,
sprivate Textview mDateDisplay:
private Button mDate:
private int mYear;
private int mMonth;
private int mDay;
Static final int DATE-DAALOG-ID=O;
H¡ù˜ On create () ªñˆî®¬ù à¼õ£‚è
«õ‡´‹.
ºîL™ GóL¬ù main.xml -Ÿ° ܬñˆ
Fì «õ‡´‹. H¡ù˜ ªì‚v† MÎ ñŸÁ‹
ð†ìQ¬ù FindviewById(int) Íô‹
«ôܾ† ®™ Þ¼‰¶ ªðø «õ‡´‹. viewon
clicklistee ner Íô‹ ð†ìQ¬ù AO‚
ªêŒ»‹«ð£¶ showDialog(int) ªêò™ð´ˆ¶‹.
H¡ù˜ è£ô‡ìKL¼‰¶ ݇´, ñ£î‹
ñŸÁ‹ «îF ÝAò îèõ™è¬÷ ªðŸÁ H¡ù˜
updateDisplay() ªñˆî† ܬö‚èŠð†´
ªì‚v† MÎM™  «î˜‰ªî´‚°‹ «îF
«î£¡Á‹. «ì†ì£H‚è˜ ìòô£‚AŸè£ù
(DataPicker Dialog) Gó™ 9-™ ªè£´‚èŠð†
´œ÷¶. DataPicker Dialog «î£¡Á‹ F¬ó
ðì‹ 7- ™ 裇H‚èŠð†´œ÷¶.
Notification in Android App (in tamil)

Más contenido relacionado

La actualidad más candente

Pogram menghitung bangun datar dan ruang dengan java
Pogram menghitung bangun datar dan ruang dengan javaPogram menghitung bangun datar dan ruang dengan java
Pogram menghitung bangun datar dan ruang dengan java
Lendra Susanto
 

La actualidad más candente (20)

George McCaskey's handling of the Ray McDonald affair offers a lesson to the ...
George McCaskey's handling of the Ray McDonald affair offers a lesson to the ...George McCaskey's handling of the Ray McDonald affair offers a lesson to the ...
George McCaskey's handling of the Ray McDonald affair offers a lesson to the ...
 
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
 
Best gourmet market
Best gourmet marketBest gourmet market
Best gourmet market
 
Check out our photos of the Pixies' Metro show
Check out our photos of the Pixies' Metro showCheck out our photos of the Pixies' Metro show
Check out our photos of the Pixies' Metro show
 
2015 Key Ingredient Cook-Off
2015 Key Ingredient Cook-Off2015 Key Ingredient Cook-Off
2015 Key Ingredient Cook-Off
 
Best hotel
Best hotelBest hotel
Best hotel
 
Skaters and BMXers from all over the U.S. descend on Grant Park
Skaters and BMXers from all over the U.S. descend on Grant ParkSkaters and BMXers from all over the U.S. descend on Grant Park
Skaters and BMXers from all over the U.S. descend on Grant Park
 
Pimp your site with jQuery!
Pimp your site with jQuery!Pimp your site with jQuery!
Pimp your site with jQuery!
 
Get more votes!
Get more votes!Get more votes!
Get more votes!
 
jQueryチュートリアル
jQueryチュートリアルjQueryチュートリアル
jQueryチュートリアル
 
Sis quiz
Sis quizSis quiz
Sis quiz
 
Here's the Downtown Sound lineup for 2015
Here's the Downtown Sound lineup for 2015Here's the Downtown Sound lineup for 2015
Here's the Downtown Sound lineup for 2015
 
Prototype UI
Prototype UIPrototype UI
Prototype UI
 
Web components v1 intro
Web components v1 introWeb components v1 intro
Web components v1 intro
 
Javascript技巧参考大全
Javascript技巧参考大全Javascript技巧参考大全
Javascript技巧参考大全
 
Java term project final
Java term project finalJava term project final
Java term project final
 
Creating List in Android App (in tamil)
Creating List in Android App (in tamil)Creating List in Android App (in tamil)
Creating List in Android App (in tamil)
 
Pogram menghitung bangun datar dan ruang dengan java
Pogram menghitung bangun datar dan ruang dengan javaPogram menghitung bangun datar dan ruang dengan java
Pogram menghitung bangun datar dan ruang dengan java
 
jQuery sans jQuery
jQuery sans jQueryjQuery sans jQuery
jQuery sans jQuery
 
Test
TestTest
Test
 

Destacado

Destacado (19)

Methods of research
Methods of researchMethods of research
Methods of research
 
Inducción sena
Inducción senaInducción sena
Inducción sena
 
СТРАТЕГИЧЕСКОЕ УПРАВЛЕНИЕ (Ten3 мини-курс)
СТРАТЕГИЧЕСКОЕ УПРАВЛЕНИЕ (Ten3 мини-курс)СТРАТЕГИЧЕСКОЕ УПРАВЛЕНИЕ (Ten3 мини-курс)
СТРАТЕГИЧЕСКОЕ УПРАВЛЕНИЕ (Ten3 мини-курс)
 
Web 2.0 and the Digital Divide
Web 2.0 and the Digital DivideWeb 2.0 and the Digital Divide
Web 2.0 and the Digital Divide
 
The Personal Research Portal
The Personal Research PortalThe Personal Research Portal
The Personal Research Portal
 
Community managers: la dirección de RR.PP. en la red
Community managers: la dirección de RR.PP. en la redCommunity managers: la dirección de RR.PP. en la red
Community managers: la dirección de RR.PP. en la red
 
ソーシャルメディア全盛時代のスマートフォン事業機会への取り組み
ソーシャルメディア全盛時代のスマートフォン事業機会への取り組みソーシャルメディア全盛時代のスマートフォン事業機会への取り組み
ソーシャルメディア全盛時代のスマートフォン事業機会への取り組み
 
Reunião de mães (1)
 Reunião de mães (1) Reunião de mães (1)
Reunião de mães (1)
 
Trabajo tecp
Trabajo tecpTrabajo tecp
Trabajo tecp
 
Sistema operativos mas usados
Sistema operativos mas usadosSistema operativos mas usados
Sistema operativos mas usados
 
Elecciones
EleccionesElecciones
Elecciones
 
T226e01
T226e01 T226e01
T226e01
 
Executive Headhunt
Executive HeadhuntExecutive Headhunt
Executive Headhunt
 
Lâ´appuntamento
Lâ´appuntamentoLâ´appuntamento
Lâ´appuntamento
 
Prefixes related to position
Prefixes related to positionPrefixes related to position
Prefixes related to position
 
Идеальный сайт с точки зрения поисковиков
Идеальный сайт с точки зрения поисковиковИдеальный сайт с точки зрения поисковиков
Идеальный сайт с точки зрения поисковиков
 
Erros e exceções
Erros e exceçõesErros e exceções
Erros e exceções
 
Chamber Quantification 2015
Chamber Quantification 2015Chamber Quantification 2015
Chamber Quantification 2015
 
Open Geodata In De Praktijk
Open Geodata In De PraktijkOpen Geodata In De Praktijk
Open Geodata In De Praktijk
 

Más de Dr. Ramkumar Lakshminarayanan

Más de Dr. Ramkumar Lakshminarayanan (20)

IT security awareness
IT security awarenessIT security awareness
IT security awareness
 
Basics of IT security
Basics of IT securityBasics of IT security
Basics of IT security
 
IT Security Awareness Posters
IT Security Awareness PostersIT Security Awareness Posters
IT Security Awareness Posters
 
Normalisation revision
Normalisation revisionNormalisation revision
Normalisation revision
 
Windows mobile programming
Windows mobile programmingWindows mobile programming
Windows mobile programming
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Web technology today
Web technology todayWeb technology today
Web technology today
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Phonegap for Android
Phonegap for AndroidPhonegap for Android
Phonegap for Android
 
Create and Sell Android App (in tamil)
Create and Sell Android App (in tamil)Create and Sell Android App (in tamil)
Create and Sell Android App (in tamil)
 
Android Tips (Tamil)
Android Tips (Tamil)Android Tips (Tamil)
Android Tips (Tamil)
 
Android Animation (in tamil)
Android Animation (in tamil)Android Animation (in tamil)
Android Animation (in tamil)
 
Single Touch event view in Android (in tamil)
Single Touch event view in Android (in tamil)Single Touch event view in Android (in tamil)
Single Touch event view in Android (in tamil)
 
Android Application using seekbar (in tamil)
Android Application using seekbar (in tamil)Android Application using seekbar (in tamil)
Android Application using seekbar (in tamil)
 
Creating Image Gallery - Android app (in tamil)
Creating Image Gallery - Android app (in tamil)Creating Image Gallery - Android app (in tamil)
Creating Image Gallery - Android app (in tamil)
 
GPS in Android (in tamil)
GPS in Android (in tamil)GPS in Android (in tamil)
GPS in Android (in tamil)
 
Using many languages in single Android App (in tamil)
Using many languages in single Android App (in tamil)Using many languages in single Android App (in tamil)
Using many languages in single Android App (in tamil)
 
Shared Preference in Android App
Shared Preference in Android AppShared Preference in Android App
Shared Preference in Android App
 
Data Storage in Android App
Data Storage in Android AppData Storage in Android App
Data Storage in Android App
 
Part 7
Part 7Part 7
Part 7
 

Notification in Android App (in tamil)

  • 1. ðô Å›G¬ôèO™ ðò÷£˜èÀ‚° îèõ™ è¬÷ ªîKMŠð Notification º¬ø ðò¡ð´Aø¶. «ï£†®çH«èê¬ù Í¡Á º¬øèO™ ݇†ó£Œ®™ à¼õ£‚è º®»‹. 1. «ì£v† «ï£†®çH«èê¡ (Toast Notifi cation) 2. v«ì†ìv 𣘠«ï£†®çH«èê¡ (Status Bar Notification) 3. ìòô£‚ «ï£†® çH«èê¡ (Dialog Notification) «ì£v† «ï£†®çH«èê¡ (Toast Notification) «ì£v† «ï£†® çH«èê¡ ðò¡ð£† ®™ àœ÷ F¬óJ™ «î£¡Á‹. ªð¼‹ð£ ½‹ å¼ ªêò™ ï¬ì ªðŸÁœ÷¶ â¡ ðî¬ù ðòù£÷˜ èÀ‚° ªîKMŠð «ì£v† ðò¡ð´A ø¶. ꣡ø£è Üô£˜‹ «ïóˆF¬ù ñ£ŸPò ¾ì¡ «ïó‹ ñ£P»œ÷¶ â¡ðî¬ùˆ ªîK MŠð‹, îèõ™ «ì†ì£«ðC™ «êI‚ èŠð´œ÷¶ â¡ð î¬ùˆ ªîKMŠðîŸ °‹ ðò¡ð´Aø¶. v«ì†ìv 𣘠«ï£†®çH«èê¡ (Status Bar Notifica- tion) v«ì†ìv 𣘠«ï£†®H«èê¡ÜŠO «èê¡ «ñ™ð°FJ™ «î£¡Á‹. ꣡ø£è, âvâ‹âv õ‰¶œ÷¶ â¡ð¬î ªîKMˆ¶ ܉î îèõ¬ô «î˜‰ªî´ˆî£™ âvâ‹âv J¬ù ð®‚èô£‹. ¹Fò ÜŠO«èê¡ GÁ¾Al˜ èœ, GÁMò¾ì¡ v«ì†ìv«ï£†® H«èê¡ Íô‹ GÁ¾ î™ º®‰¶ M†ì¶ â¡ðî¬ù ªîKòŠ ð´ˆîô£‹. ܉î v«ì†ìv 𣘠«ï£†®H«èê¬ù AO‚ ªêŒ¶ 𣘈 ðòù£÷¼‚° â¡ù ï¬ì ªðŸÁœ÷¶ â¡ø îèõ™ «î£¡Áñ£Á à¼õ£‚°õ v«ì†ìv 𣘠«ï£†® H«èê¡ ðò¡ð´ Aø¶. îèõ™ ªîKM‚°‹ º¬ø ìòô£‚ «ï£†®çH«èê¡ (Dialog Notification) ªêò™ð†´ ªè£‡®¼‚°‹ Ý‚®M† ®‚° (Activity) «ñ«ô îèõ¬ôˆ ªîKMˆ¶, H¡ù˜ ܉î F¬óJ™ «î˜‰ªî´‚°‹ àœ k†®Ÿ° ãŸð ªêò™è¬÷ ñ£ŸP ܬñ‚è ìòô£è «ï£†®çH«èê¡ ðò¡ð´Aø¶. ꣡ ø£è å¼ F¬óJL¼‰¶ ñŸªø£¼ F¬ó‚° ªê™õ ðòù£÷¼‚° æ.«è. ñŸÁ‹ «è¡ê™ â¡ø «î˜M¬ù ÜOˆ¶, æ.«è. ªè£´ˆî£™ Ü´ˆî F¬ó‚° ªê™ô «õ‡´‹, «è¡ê™ ªè£´ˆî£™ Ü«î F¬óJ™ Þ¼‚è «õ‡´‹ «ð£¡ø ªêò™ð£†®¬ù à¼õ£‚è ìòô£‚ «ï£†®çH«èê¡ ðò¡ð´Aø¶. «ì£v† «ï£†®çH«èê¬ù ݇†ó£Œ´ ÜŠO‚«èêQ™ ðò¡ð´ˆ¶õ «ì£v† ÝŠªü‚† ðò¡ð´Aø¶. îèõ™è¬÷ F¬ó J™ 裇ð makeText() ªñˆî®Ÿ° Í¡Á Mîñ£ù îèõ™è¬÷ ªè£´‚è «õ‡´‹. ܬõ â‰î F¬ó, â¡ù îèõ™ ñŸÁ‹ âš õ÷¾ «ïó‹ â¡ðùõŸ¬ø ªè£´‚è «õ‡ ´‹. «ì£v†®¬ù ÜŠO‚«èêQ™ 裇 HŠð show() ªñˆî† ðò¡ð´Aø¶. ꣡ ø£è, (Gó™-1) ðì‹-1 ðì‹-2 ðì‹-3 Gó™-1 Gó™-2 Gó™-3
  • 2. Toast F¬óJ¡ â‰îŠ ð°FJ™ «î£¡ø «õ‡´‹ â¡ðî¬ù °PŠð setGravity() ªñˆî† ðò¡ð´Aø¶. ꣡ø£è, toast.setGravity(Gravity.Top,o,o,); Ü™ô¶ toast.setGravity(Gravity.LEFT,O,O); Ü´ˆ¶ «ï£†®çH«èê¬ù, v«ì†ìú ð£K™ à¼õ£‚°‹ º¬øJ¬ù 𣘊«ð£‹. ¹Fò Šó£ªü‚† å¡P¬ù à¼õ£‚°«õ£‹. Project Name â¡ðî¬ù Notification Manager âù ¬õˆ¶‚ ªè£œ«õ£‹. Ý‚®M†® ªðòK¬ù Create Notification âùŠ ªðòK´ «õ£‹. ÜF™ mail.xml -Ÿè£ù «è£´ (code) Gó™ 2-™ ªè£´‚èŠð†´œ÷¶. Ü´ˆîî£è result.xml â¡ø ç¬ðL¬ù Gó™ 3-™ àœ÷¶ «ð£¡Á à¼õ£‚è «õ‡´‹. result.xml ‚è£ù Activity Notification Receiver â¡ð‹. ÜF™ Ý¡†ó£Œ´ -2 Þ󣋰ñ£˜ ªô†²Iï£ó£òí¡ 06 import android.app.Activity; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Intent; import android.os.Bundle; import android.view.View; public class CreateNotification extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } public void createNotification(View view) { NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.icon, "A new notification", System.currentTimeMillis()); // Hide the notification after its selected notification.flags |= Notification.FLAG_AUTO_CANCEL; Intent intent = new Intent(this, NotificationReceiver.class); PendingIntent activity = PendingIntent.getActivity(this, 0, intent, 0); notification.setLatestEventInfo(this, "This is the title", "This is the text", activity); notification.number += 1; notificationManager.notify(0, notification); <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/ apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/button1" android:text="@string/btn_name"></Button> </LinearLayout> Gó™-4 Gó™-5 Gó™-6
  • 3. package com.ram.dialogex; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.widget.*; public class DialogExActivity extends Activity { /** Called when the activity is first created. */ Button b1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); b1 = (Button)findViewById(R.id.button1); b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub AlertDialog alertDialog = new AlertDialog.Builder(DialogExActivity.this).creat e(); alertDialog.setTitle("Reset..."); alertDialog.setMessage("R u sure?"); alertDialog.setIcon(R.drawable.icon); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //here you can add functions } }); alertDialog.show(); } }) ; } } ðì‹-4 ðì‹-5 Gó™-7 Gó™-8 Gó™ A™ àœ÷¶ «ð£¡ø Š«ó£Aó£ I¬ù à¼õ£‚è «õ‡´‹. Þ‰î ç¬ðL™ result.xml notificationmanager Activity -»ì¡ SetContentView(R.layout.result) â¡ø õKJ¡ Íô‹ ެ특 ãŸð´ˆF»œ«÷£‹. Ü´ˆ¶ CreateNotifoca t i o n- Ÿ è £ ù Gó¬ô à¼õ£ ‚è «õ‡´‹. «ï£†®çH«è êQ¬ù Þ‰î ꣡P™ CreateNotification â¡ø ªð£ˆî£¬ù‚ AO‚ ªêŒî¾ì¡ ªêò™ ï¬ìªðÁõ main.xml ç¬ðL™ «ï£†®çH«èê¡ «ñ«ù ü¬ó ðò¡ð´ˆî «õ‡´‹. CreateNotification -Ÿè£ù Gó™ ä‰F™ ªè£´‚èŠð†´œ÷¶. ÜŠO‚«èê¬ù ªêò™ð´ˆ¶õ º¡ sAndroidManifest.xml ç¬ðL™ W›‚è‡ì õK è¬÷ Þ¬í‚è «õ‡´‹. ÜŠO«èê¬ù„ ªêò™ð´ˆ¶õ sRun As -> Andriod Application â¡Á ªè£´‚è «õ‡ ´‹. F¬óJ™ «î£¡Á‹ Create Notification â¡ø ªð£ˆî£¬ù‚ AO‚ ªêŒî£™ «ï£†® çH«èê¡ v«ì†ìv 𣘠«î£¡Á‹. Ü´ˆîî£è ìòô£‚ «ï£†®çH«èêQŸ è£ù ꣡Á à¼õ£‚°‹ º¬ø¬òŠ 𣘊 «ð£‹. Dialog Notification Dialog A÷£R¬ù Ü®Šð¬ìò£è‚ ªè£‡´ à¼õ£‚èŠð´Aø¶. ìòô£‚ A÷£C¬ù Ü®Šð¬ìò£è ªè£‡´ Alert Dialog, Progress Dialog, DatePickerDialog, TimePickerDialog «ð£¡ø¬õ àœ÷ù. Ý‚® M†®J¬ùÜ®Šð¬ìò£èªè£‡«ììòô£‚
  • 4. package com.ram.datepickerexample; import android.app.Activity; import java.util.Calendar; import android.app.DatePickerDialog; import android.widget.DatePicker; import android.app.Dialog; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class DatePickerExampleActivity extends Activity { private TextView mDateDisplay; private int mYear; private int mMonth; private int mDay; static final int DATE_DIALOG_ID = 1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mDateDisplay = (TextView) findViewById(R.id.dateDisplay); Button pickDate = (Button) findViewById(R.id.pickDate); pickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDialog(DATE_DIALOG_ID); } }); final Calendar c = Calendar.getInstance(); mYear = c.get(Calendar.YEAR); mMonth = c.get(Calendar.MONTH); mDay = c.get(Calendar.DAY_OF_MONTH); updateDisplay(); } @Override protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay); } return null; } protected void onPrepareDialog(int id, Dialog dialog) { switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(mYear, mMonth, mDay); break; } } private void updateDisplay() { mDateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(mMonth + 1).append("- ") .append(mDay).append("-") .append(mYear).append(" ")); } private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { mYear = year; mMonth = monthOfYear; mDay = dayOfMonth; updateDisplay(); } }; } ðì‹-6 Gó™-9 à¼õ£‚èŠð´‹. Ý‚®M†®JL¼‰¶ ìòô£‚ à¼õ£‚°õ OnCreateDialog(int) â¡ø ªñˆî† ðò¡ð´Aø¶. Üô£˜† ìòô£‚ ªêòL¬ù ÜP‰¶ ªè£œ õ ¹Fò Šó£ªü‚† Ýè Dialog Ex â¡ ðî¬ù à¼õ£‚°«õ£‹. ÞF™ Button å¡P¬ù à¼õ£‚A Üî¬ù AO‚ ªêŒî£™ Üô£˜† ìòô£‚ «î£¡Á‹. ÞîŸè£ù «ôܾ† ç¬ð™ main.xml Ý°‹. (Gó™ 6) main.xml L™ à¼õ£‚A àœ÷ ªð£ˆî£Q¡ ªðò˜ Button 1 â¡ð‹. ªð£ˆ ù DialogExActivity -J™ ެ특 ãŸð´ˆî ºîL™ ªð£ˆî£¡ ÝŠªü‚®¬ù à¼õ£‚è «õ‡´‹. Button b1 ; H¡¹ b1 = (Button) findViewById(R.id.button1); â¡Á ðò¡ð´ˆî «õ‡´‹. ªð£ˆî£¬ù‚ AO‚ ªêŒî£™ ªêò™ ï¬ìªðÁõ b1. SetOnClickListener(); â¡ðî¬ù ðò¡ð´ˆî «õ‡´‹. Üô£˜†ìòô£‚A¬ùà¼õ£‚° õ Alert.Dialog.Builder ðò¡ ð´Aø¶.
  • 5. - ªî£ì¼‹ ðì‹-7 AlertDialog alertdialog=new AlertDialog. Builder(DialogExActivity.this).create Ý°‹. Üô£˜† ìòô£‚ ªêò™ð£†®Ÿè£ù Gó™ 7-™ ªè£´‚èŠð†´œ÷¶. ÜîŸè£ù F¬ó ðì‹ 5-™ àœ÷¶ «ð£¡Á «î£¡Á‹. Ü´ˆîî£è Progress Dialog ðò¡ð´ˆ¶‹ º¬øJ¬ù 𣘊«ð£‹. ꣡ø£è, ProgressDialog dialog = progressDialog.show( DialogExActivity.this,"", "Please Wait for few Seconds...",true); Progress Dialog -J¬ù GÁˆ¶õîŸè£ù ðò¡ð£´. ProgressDialogName.dismiss();  ðò¡ð´ˆF àœ÷ ꣡P™ dialog. dismiss(),; â¡Á ðò¡ð´ˆî «õ‡´‹. Progress Dialog ÜŠO‚«èêQ™F¬ó 6-™ àœ÷¶ «ð£¡Á «î£¡Á‹. Date Picker Dialog -J¬ù à¼õ£‚è main. xml ç¬ðL¬ù «ôܾ† Ýè ܬñˆ¶ Text View ñŸÁ‹ Button Þ¼‚°ñ£Á à¼õ£‚è «õ‡´‹. ð†ìQ¬ù‚ AO‚ ªêŒî£™ Date Picker Dialog «î£¡Áñ£Á Date Picker Example Activity -J¬ù à¼õ£‚è «õ‡´‹. DatePickerExampleActivity.java â¡ø Class ç¬ðL™ Cô Member è¬÷ Þ¬í‚è «õ‡´‹. ܬõ, sprivate Textview mDateDisplay: private Button mDate: private int mYear; private int mMonth; private int mDay; Static final int DATE-DAALOG-ID=O; H¡ù˜ On create () ªñˆî®¬ù à¼õ£‚è «õ‡´‹. ºîL™ GóL¬ù main.xml -Ÿ° ܬñˆ Fì «õ‡´‹. H¡ù˜ ªì‚v† MÎ ñŸÁ‹ ð†ìQ¬ù FindviewById(int) Íô‹ «ôܾ† ®™ Þ¼‰¶ ªðø «õ‡´‹. viewon clicklistee ner Íô‹ ð†ìQ¬ù AO‚ ªêŒ»‹«ð£¶ showDialog(int) ªêò™ð´ˆ¶‹. H¡ù˜ è£ô‡ìKL¼‰¶ ݇´, ñ£î‹ ñŸÁ‹ «îF ÝAò îèõ™è¬÷ ªðŸÁ H¡ù˜ updateDisplay() ªñˆî† ܬö‚èŠð†´ ªì‚v† MÎM™  «î˜‰ªî´‚°‹ «îF «î£¡Á‹. «ì†ì£H‚è˜ ìòô£‚AŸè£ù (DataPicker Dialog) Gó™ 9-™ ªè£´‚èŠð† ´œ÷¶. DataPicker Dialog «î£¡Á‹ F¬ó ðì‹ 7- ™ 裇H‚èŠð†´œ÷¶.