简体   繁体   中英

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

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM