无法在我的自定义android应用程序中启动DayDream服务
我正在尝试开发一款内置白日梦功能的应用程序。我指的是以下教程: 在“设置>显示>白日梦”下,我可以在应用程序列表中看到我的应用程序,但当我尝试启动它时,什么都没有发生。我不明白出了什么问题 以下是我的代码, 清单文件:无法在我的自定义android应用程序中启动DayDream服务,android,daydream,Android,Daydream,我正在尝试开发一款内置白日梦功能的应用程序。我指的是以下教程: 在“设置>显示>白日梦”下,我可以在应用程序列表中看到我的应用程序,但当我尝试启动它时,什么都没有发生。我不明白出了什么问题 以下是我的代码, 清单文件: 您的目标是api级别21或更高。您需要设置绑定梦想服务的服务权限来实现您的梦想: <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@str
您的目标是api级别21或更高。您需要设置绑定梦想服务的服务权限来实现您的梦想:
<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>
有人能告诉我如何启动这项服务以在屏幕上启用“白日梦”吗?
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);
}
}
<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>