I am trying to develop an app which has a daydream feature built in it. I am referring the following tutorial:
http://www.technotalkative.com/how-to-create-daydream/
Under Setting>Display>DayDream, I am able to see my application in the list of apps but when I try to start it, nothing happens. I am not able to understand what is going wrong.
Following is my code regarding the same, Manifest file:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<service
android:name=".MyDreamService"
android:exported="true"
android:label="Test - DayDream" >
<intent-filter>
<action android:name="android.service.dreams.DreamService" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
</application>
Class file:
import android.graphics.Color;
import android.service.dreams.DreamService;
import android.widget.TextView;
public class MyDreamService extends DreamService {
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
// Allow user touch
setInteractive(true);
// Hide system UI
setFullscreen(true);
// Set the dream layout
TextView txtView = new TextView(this);
setContentView(txtView);
txtView.setText("Hello DayDream world from TechnoTalkative.com !!");
txtView.setTextColor(Color.rgb(184, 245, 0));
txtView.setTextSize(30);
}
}
You are targeting api level 21 or above. You need to set the BIND_DREAM_SERVICE service permission to fulfill your daydream:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<service
android:name=".MyDreamService"
android:exported="true"
android:label="Test - DayDream"
android:permission="android.permission.BIND_DREAM_SERVICE"**>
<intent-filter>
<action android:name="android.service.dreams.DreamService" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With