Reputation: 1609
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)?
Upvotes: 3
Views: 1528
Reputation: 1725
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 */ } } }
Upvotes: 2
Reputation: 2551
As DreamService
inherits from Service
it should be possible to dynamically start them by using startService.
Upvotes: 0