package
kr.pe.theeye.gobackground;
import
java.text.ParseException;
import
java.text.SimpleDateFormat;
import
java.util.Date;
import
android.app.AlarmManager;
import
android.app.PendingIntent;
import
android.app.Service;
import
android.content.Intent;
import
android.os.IBinder;
import
android.util.Log;
public
class
BootSvc
extends
Service {
@Override
public
IBinder onBind(Intent arg0) {
return
null
;
}
@Override
public
void
onCreate(){
super
.onCreate();
Log.i(
"0000aaa"
,
"서비스 시작은 재부팅 후에"
);
}
public
void
registerAlarm()
{
Log.e(
"###"
,
"registerAlarm"
);
Intent intent =
new
Intent(
this
, BootSvc.
class
);
PendingIntent sender = PendingIntent.getBroadcast(
this
,
0
, intent,
0
);
try
{
Date tomorrow =
new
SimpleDateFormat(
"yyyy-MM-dd hh:mm:ss"
).parse(
"2015-08-19 17:12:00"
);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.setInexactRepeating(AlarmManager.RTC, tomorrow.getTime(),
24
*
60
*
60
*
1000
, sender);
}
catch
(ParseException e)
{
e.printStackTrace();
}
}
}