안드로이드 공부하는 초보 학생입니다

 

알람을 만들고 있는데 기존에는 액티비티에서 setAlarm()호출하여

 

 // 알람의 설정
  public  void setAlarm() {
  Log.d("woo","setAlarm1");
  mManager.set(AlarmManager.RTC_WAKEUP, mCalendar.getTimeInMillis(),
    pendingIntent());
  Log.d("woo","setAlarm2");
  Toast.makeText(Alarm_time.this, "알람설정완료", Toast.LENGTH_LONG).show();

 }

 // 알람의 설정 시각에 발생하는 인텐트 작성
  public  PendingIntent pendingIntent() {
  Log.d("woo","pendingIntent1");
  Intent i = new Intent(getApplicationContext(), Alarm_sound.class);
  PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0);
  Log.d("woo","pendingIntent2");
  return pi;
 }

 

요로코롬 했었는데 생각해보니 서비스로 돌려야하더라고요 ㅠㅠ

 

그래서 일단 부팅시 서비스 동작하게 하고 액티비티에서 서비스 호출하여 서비스에서는 액티비티의 setAlarm()을 호출하면 될거 같아서

 

해봤는데 setAlarm(),pendingIntent()을 static 하니깐 오류가나네요 ㅠ

 

  Intent i = new Intent(getApplicationContext(), Alarm_sound.class);
  PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0);
 

저부분들이 빨간줄이뜨네요 ㅠㅠ  액티비티에 있는 pendingIntent는 static으로 해서 서비스에서 호출 못하나여?

 

다른방법으로 해야한다면 자세한 설명좀 부탁드리겠습니다 ㅠㅠ 초보라서 그런데 예제까지 올려주시면 정말 감사하겠습니다!