I want to write a application which can change the daydream setting. It will require to set the my own dream as selected and also make the when to play option as "Either". Is that possible to implement this feature in the sdk version 19?
1 Answers
If you want to set the daydream for the user, you cannot do this. You can, however, open the system settings in the right location so that the user can select from installed daydreams.
You can provide a button to access Daydream Settings like so:
public void onSettingsButtonClick(View v) {
Intent intent;
if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR2) {
intent = new Intent(Settings.ACTION_DREAM_SETTINGS);
} else {
intent = new Intent(Settings.ACTION_DISPLAY_SETTINGS);
}
startActivity(intent);
}
This will take the user to either "Daydream Settings" or the "Display Settings" section of the device settings.
If you'd like the user to be able to go from the device settings to a specific activity for configuring your daydream, you can add the <meta-data/>
tag here as an element of your Daydream service in your manifest:
<service
android:name="some.package.SomeDaydream"
android:exported="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.service.dreams.DreamService" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.service.dream"
android:resource="@xml/dream_info" />
</service>
When targeting api level 21 and above, you must declare the service in your manifest file with the BIND_DREAM_SERVICE permission. For example:
android:permission="android.permission.BIND_DREAM_SERVICE">
Then, in /res/xml/
, add dream_info.xml
:
<?xml version="1.0" encoding="utf-8"?>
<dream xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="some.package/.SomeActivity" />
I have an example Daydream here that shows this behaviour (in both directions).

- 4,576
- 2
- 34
- 48

- 16,144
- 6
- 54
- 81
-
Is there a way to start the user's selected daydream programmatically? I just posted a question about it here: http://stackoverflow.com/questions/21369368/how-do-you-start-the-users-selected-daydream-programmatically – Jacob Tabak Jan 26 '14 at 21:40
-
1If you have a settingsActivity, don't forget to declare it in your application's manifest file or else it won't be loaded and you'll get an error when the user tries to launch the settings page. – markmanca Mar 14 '15 at 19:56
-
android.Permission.BIND_DREAM_SERVICE will only be granted to system-apps. – laim2003 Jul 22 '19 at 11:49