http://ccdev.tistory.com/22 소스 참고했습니다.
public class ScreenService extends Service {
private ScreenReciver mReceiver = null;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate(){
super.onCreate();
mReceiver = new ScreenReciver();
IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
registerReceiver(mReceiver, filter);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId){
super.onStartCommand(intent, flags, startId);
startForeground(1, new Notification());
Notification notification = new Notification(R.drawable.a_launcher, "서비스 실행됨", System.currentTimeMillis());
notification.setLastestEventInfo(getApplicationContext(), "Screen Service", "Foreground로 실행됨", null);
startForeground(1, notification);
if (intent != null) {
if ( intent.getAction() == null) {
if (mReceiver == null ) {
mReceiver = new ScreenReciver();
IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
registerReceiver(mReceiver, filter);
}
}
}
return START_REDELIVER_INTENT;
}
@Override
public void onDestory() {
super.onDestroy();
if(mReceiver != null) {
unregisterReceiver(mReceiver);
}
}
}
Error:(38, 21) error: cannot find symbol method setLatestEventInfo(Context,String,String,<null>)
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Error:(53, 5) error: method does not override or implement a method from a supertype
도와주시면 감사하겠습니다 ㅠㅠ 초보라서 아직 미숙한점이 많네요..
하루종일 고민하고 수정해봐도 오류뜨네요