2013-04-17 3 views
3

DreamService를 사용중인 응용 프로그램을 개발 중입니다. 그러나 빌트인 옵션은 충전과 도킹을하는 동안에도 항상 공상을 시작할 수 있습니다. 응용 프로그램을 실행하는 동안 공상을 불러올 수있는 솔루션이 있습니까 (예 : 5 초 동안 장치가 비활성 상태 인 동안)?Android : DayDream in Application

답변

0

DreamServiceService에서 상속되므로 startService을 사용하여 동적으로 시작할 수 있어야합니다.

+0

의'onStartCommand' 방법은'DreamService' 서브 클래스에서 호출되었지만하지 onAttachToWindow'와'onDreamingStarted''같은 백일몽 수명주기 방법. – Michiyo

1

대답

... 늦게 년이며, 5 초 문제에 대한 비활성를 해결하지 않습니다,하지만 여전히 유용 할 수 있습니다 프로젝트에 다음과 같은 DreamNow.java에게 파일을 추가하고 DreamNow 클래스로 활동을 확장하십시오. 나는이 시도

import android.app.Activity; 
import android.content.Intent; 

/** 
* To use, replace "extends Activity" in your activity with "extends DreamNow". 
* 
* From the Google Android Blog Daydream example. 
*/ 
public class DreamNow extends Activity { 
    @Override 
    public void onStart() { 
     super.onStart(); 
     final Intent intent = new Intent(Intent.ACTION_MAIN); 

     try { 
      // Somnabulator is undocumented--may be removed in a future version... 
      intent.setClassName("com.android.systemui", 
           "com.android.systemui.Somnambulator"); 
      startActivity(intent); 
      finish(); 

     } catch (Exception e) { /* Do nothing */ } 
    } 
}