Notification소스를 인터넷에서 찾아왔는데
전반적으로 어떻게 돌아가는지 설명좀 부탁드립니다. ㅠㅠ
package ex.woojin.exam;
import android.app.*;
import android.content.*;
import android.os.*;
import android.view.*;
import android.widget.*;
public class NotificationAlarm extends Activity {
static final int NAPNOTI = 1;
NotificationManager mNotiManager;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.service_napalarm);
mNotiManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Button btn = (Button)findViewById(R.id.start);
btn.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Message msg = Message.obtain();
msg.what=0;
h.sendMessageDelayed(msg , 5000);
}
});
}
Handler h =new Handler(){
public void handleMessage(Message msg) {
if(msg.what==0){
NotiThread thread = new NotiThread();
thread.setDaemon(true);
thread.start();
}
};
};
class NotiThread extends Thread{
@Override
public void run() {
Notification noti = new Notification(R.drawable.napalarm,
"일어날 시간입니다.!!", System.currentTimeMillis());
noti.defaults |= Notification.DEFAULT_SOUND;
noti.vibrate = new long[] {1000,1000,500,500,200,200,200,200,200,200};
noti.flags |= Notification.FLAG_INSISTENT;
noti.flags |= Notification.FLAG_AUTO_CANCEL;
Intent intent = new Intent(NotificationAlarm.this , AlramSubActivity.class);
PendingIntent pend = PendingIntent.getActivity(NotificationAlarm.this,
0, intent, 0);
noti.setLatestEventInfo(NotificationAlarm.this,
"집에갑시다!", "오늘도 수고하셨습니다. 낼도 화이팅!", pend);
mNotiManager.notify(NAPNOTI, noti);
}
}
}



