안드로이드 개발 질문/답변
(글 수 45,052)
브로드케스트리시버를 등록을 했고요..
Intent i=new Intent(context,main.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
요렇게 하면 이제 Activity로 가잖아요??
근데 서비스는 어떻게 해야 하는지...ㅜ.ㅜ
Activity에서.. 서비스 호출하는 방법은..
final Intent i=new Intent(this,MyService.class);
sender=PendingIntent.getService(this, 0, intent, 0);
am=(AlarmManager)getSystemService(ALARM_SERVICE);
long nowTime=System.currentTimeMillis();
am.set(AlarmManager.RTC_WAKEUP, nowTime, sender);
이런식으로..구현하면 서비스가 등록 되던데요.. 브로드케스터에서는..
final Intent i=new Intent(context,MyService.class);
sender=PendingIntent.getService(context, 0, intent, 0);
am=(AlarmManager)getSystemService(ALARM_SERVICE);
long nowTime=System.currentTimeMillis();
am.set(AlarmManager.RTC_WAKEUP, nowTime, sender);
이렇게 this 대신에 context를 사용하면 될줄 알았지만..
ALARM_SERVICE부분에서 에러가 뜨네요....
꼭 broadcastReceiver를 통해서 서비스 등록하려고 했는데...
broadcastRecevier->Activity(Service 실행 후 종료)->Service
이런식으로 호출해야 할까요..?
Intent i=new Intent(context,main.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
요렇게 하면 이제 Activity로 가잖아요??
근데 서비스는 어떻게 해야 하는지...ㅜ.ㅜ
Activity에서.. 서비스 호출하는 방법은..
final Intent i=new Intent(this,MyService.class);
sender=PendingIntent.getService(this, 0, intent, 0);
am=(AlarmManager)getSystemService(ALARM_SERVICE);
long nowTime=System.currentTimeMillis();
am.set(AlarmManager.RTC_WAKEUP, nowTime, sender);
이런식으로..구현하면 서비스가 등록 되던데요.. 브로드케스터에서는..
final Intent i=new Intent(context,MyService.class);
sender=PendingIntent.getService(context, 0, intent, 0);
am=(AlarmManager)getSystemService(ALARM_SERVICE);
long nowTime=System.currentTimeMillis();
am.set(AlarmManager.RTC_WAKEUP, nowTime, sender);
이렇게 this 대신에 context를 사용하면 될줄 알았지만..
ALARM_SERVICE부분에서 에러가 뜨네요....
꼭 broadcastReceiver를 통해서 서비스 등록하려고 했는데...
broadcastRecevier->Activity(Service 실행 후 종료)->Service
이런식으로 호출해야 할까요..?