검색을 해보면.. Intent.ACTION_BOOT_COMPLETED 를사용하라고.. 그러는데..
정확히 어떻게 사용하는지 알기가 어려워서 이렇게 질문 올립니다...;
사용하는 곳과... 사용할 때 제가 보기엔 알람서비스를 다시 입력하는거같은데.. 그럼 디비에 잇는걸 불러서 다시 입력하는건가요..??
저걸사용하면 부팅시에 바로 실행되게만 하는건가요? 부팅전 내용을 어디 기억시키는게 아니라...?
BroadcastReceiver 를 액티비티처럼
클래스 만들구요 extends 하시고
매니패스트에 등록하시면 됩니다.
그러니까 액티비티->브로드캐스트 문자만 바뀌고 등록법은 액티비티랑 똑같구요..
매니패스트에 등록하시면
<receiver android:name=".KDBroadCast">
</receiver>
매니패스트 소스에 이렇게 등록될건데 이걸
<receiver android:name=".KDBroadCast">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="com.kd">
</action>
</intent-filter>
</receiver>
이렇게 고쳐주시면 됩니당
btn.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v){
String n1,n2,n3;
n1=sigan.getText().toString();
n2=boon.getText().toString();
n3=cho.getText().toString();
if(n1.equalsIgnoreCase(""))
{
n1="0";
}
if(n2.equalsIgnoreCase(""))
{
n2="0";
}
if(n3.equalsIgnoreCase(""))
{
n3="0";
}
long num1 = Integer.parseInt(n1);
long num2 = Integer.parseInt(n2);
long num3 = Integer.parseInt(n3);
long hab;
hab = ((num1*60*60*1000)+(num2*60*1000)+(num3*1000));
v.postDelayed(new Runnable() {
public void run(){
Notification noti = new Notification(R.drawable.bg,"알람입니다.",System.currentTimeMillis());
noti.vibrate = new long[]{1000,1000};
noti.defaults |= Notification.DEFAULT_SOUND ;
noti.flags |= Notification.FLAG_INSISTENT;
Intent intent = new Intent(smalarm.this, End.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent content = PendingIntent.getActivity(smalarm.this, 0, intent, 0);
noti.setLatestEventInfo(smalarm.this, " 알람", "시간이 되었습니다.",content);
mNotiManager.notify(smalarm.NAPNOTI, noti);
}
}, hab );
}
});
이런소스를 액티비티에 넣었는데요... 이걸 브로드캐스트에 넣을려면 그냥 바꾸기만하면 되나요..??
시스템에서 부팅시에 위의 BroadCast 를 날려줍니다.
BroadcastReceiver 를 만들어서 위의 Intent 를 filter 에 등록해주면 됩니다.