How do I run an Android Dream Service as (or within) an Activity?

1k Views Asked by At

I have a perfectly functioning DreamService that I want to use within my main activity along with an extra button so that the user can access settings (Android TV appears to be missing the daydream settings icon as far as I can tell).

Is there an easy way this could be done that would specifically avoid duplication of code?

2

There are 2 best solutions below

2
On BEST ANSWER

Sure, just take the views you created for your service and put them in an activity instead. Make sure your views can work without a direct dependency on the service.

0
On

You can invoke the DayDream like this -

Intent intentDream = new Intent(Intent.ACTION_MAIN);
intentDream.setClassName("com.android.systemui", "com.android.systemui.Somnambulator");
startActivity(intentDream);

Hope this helps.