我正在尝试开发一个内置了白日梦功能的应用程序。我指的是以下教程:
http://www.technotalkative.com/how-to-create-daydream/
在设置>显示>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" >
<intent-filter>
<action android:name="android.service.dreams.DreamService" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
</application>
类文件:
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);
}
}