I'm developing application in which I'm using DreamService. But built-in options only give start daydreaming while charging and docking. Is there any solution to invoke daydreaming during executing application( while device is inactive for a while, say, 5 sec)?
Android: DayDream in Application
1.3k Views Asked by Forin At
2
There are 2 best solutions below
1

Answer is a year late and doesn't address the inactivity for 5 sec issue, but still might be useful...
Add the following DreamNow.java file to your project and extend your Activity with the DreamNow class.
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 */ } } }
As
DreamService
inherits fromService
it should be possible to dynamically start them by using startService.