DreamService 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。
[Android.Runtime.Register("android/service/dreams/DreamService", DoNotGenerateAcw=true)]
public class DreamService : Android.App.Service, Android.Views.Window.ICallback, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/service/dreams/DreamService", DoNotGenerateAcw=true)>]
type DreamService = class
inherit Service
interface Window.ICallback
interface IJavaObject
interface IDisposable
interface IJavaPeerable
- 继承
- 属性
- 实现
注解
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。
梦想是在充电设备空闲或停靠在桌面扩展坞时启动的交互式屏幕保护程序。 梦想为应用提供了另一种表达自我的方式,专为展览/后退体验而定制。
生命周期 DreamService
如下所示:
<ol><li>#onAttachedToWindow
将此用于初始设置,例如调用 #setContentView setContentView()
。</li><li>#onDreamingStarted
你的梦想已经开始了,所以你应该在这里开始动画或其他行为。</li><li>#onDreamingStopped
使用此来停止在 中启动的项 #onDreamingStarted
。</li><li>#onDetachedFromWindow
使用它可以拆除资源 (例如,从处理程序和侦听器分离) 。</li></ol>
此外,还将调用来自服务接口) 的 onCreate 和 onDestroy (,但初始化和拆解应通过重写上述挂钩来完成。
若要可供系统使用, DreamService
应在清单中声明,如下所示:
<service
android:name=".MyDream"
android:exported="true"
android:icon="@drawable/my_icon"
android:label="@string/my_dream_label" >
<intent-filter>
<action android:name="android.service.dreams.DreamService" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<!-- Point to additional information for this dream (optional) -->
<meta-data
android:name="android.service.dream"
android:resource="@xml/my_dream" />
</service>
如果使用 元素指定 <meta-data>
,则使用 单独的 XML 文件中的 元素定义 android.R.styleable#Dream <dream>
梦的其他信息。 目前,你可以提供的唯一附加信息是允许用户配置梦想行为的设置活动。 例如:
<p class=“code-描述文字”>res/xml/my_dream.xml</p>
<dream xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="com.example.app/.MyDreamSettingsActivity" />
这样,在系统设置中,“设置”按钮与梦想列表一起可用,按下该按钮将打开指定的活动。
若要指定梦寐以求的布局,请调用 #setContentView
,通常在回调期间 #onAttachedToWindow
调用 。 例如:
public class MyDream extends DreamService {
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
// Exit dream upon user touch
setInteractive(false);
// Hide system UI
setFullscreen(true);
// Set the dream layout
setContentView(R.layout.dream);
}
}
面向 API 级别 21 及更高时,必须在清单文件中声明具有 权限的服务 android.Manifest.permission#BIND_DREAM_SERVICE
。 例如:
<service
android:name=".MyDream"
android:exported="true"
android:icon="@drawable/my_icon"
android:label="@string/my_dream_label"
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>
的 android.service.dreams.DreamService
Java 文档。
此页面的部分内容是基于 创建和共享的工作进行的修改,并根据 署名许可中所述的术语使用。
构造函数
DreamService() | |
DreamService(IntPtr, JniHandleOwnership) |
创建 JNI 对象的托管表示形式时使用的构造函数;由运行时调用。 |
字段
AccessibilityService |
使用 和 |
AccountService |
使用 和 |
ActivityService |
使用 和 |
AlarmService |
使用 和 |
AppOpsService |
使用 和 |
AppSearchService |
使用 和 |
AppwidgetService |
使用 和 |
AudioService |
使用 和 |
BatteryService |
使用 和 |
BindAllowActivityStarts |
已过时.
标志 |
BindExternalServiceLong |
的工作方式与 相同 |
BindNotPerceptible |
已过时.
标志 |
BindSharedIsolatedProcess |
已过时.
标志 |
BiometricService |
与 配合使用 |
BlobStoreService |
使用 和 |
BluetoothService |
使用 和 |
BugreportService |
用于捕获 bug 报告的服务。 (继承自 Context) |
CameraService |
使用 来 |
CaptioningService |
使用 和 |
CarrierConfigService |
使用 和 |
ClipboardService |
使用 和 |
CompanionDeviceService |
使用 和 |
ConnectivityDiagnosticsService |
使用 和 |
ConnectivityService |
使用 和 |
ConsumerIrService |
使用 和 |
CredentialService |
使用 和 |
CrossProfileAppsService |
使用 和 |
DeviceIdDefault |
默认设备 ID,即主 (非虚拟) 设备的 ID。 (继承自 Context) |
DeviceIdInvalid |
设备 ID 无效。 (继承自 Context) |
DeviceLockService |
将 与 一起使用 |
DevicePolicyService |
使用 来 |
DisplayHashService |
使用 和 |
DisplayService |
使用 来 |
DomainVerificationService |
使用 和 |
DownloadService |
使用 和 |
DreamMetaData |
Dream 发布有关自身信息的名称。 |
DropboxService |
使用 和 |
EuiccService |
使用 和 |
FileIntegrityService |
将 与 配合使用 |
FingerprintService |
使用 和 |
GameService |
将 与 一起使用 |
GrammaticalInflectionService |
将 与 一起使用 |
HardwarePropertiesService |
使用 和 |
HealthconnectService |
将 与 一起使用 |
InputMethodService |
使用 和 |
InputService |
使用 来 |
IpsecService |
使用 和 |
JobSchedulerService |
使用 和 |
KeyguardService |
使用 和 |
LauncherAppsService |
使用 和 |
LayoutInflaterService |
使用 和 |
LocaleService |
将 与 一起使用 |
LocationService |
使用 和 |
MediaCommunicationService |
将 与 一起使用 |
MediaMetricsService |
使用 和 |
MediaProjectionService |
使用 和 |
MediaRouterService |
使用 和 |
MediaSessionService |
使用 和 |
MidiService |
将 与 一起使用 |
NetworkStatsService |
将 与 一起使用 |
NfcService |
使用 与 |
NotificationService |
使用 和 |
NsdService |
将 与 一起使用 |
OverlayService |
使用 和 |
PeopleService |
使用 和 |
PerformanceHintService |
将 与 一起使用 |
PowerService |
使用 和 |
PrintService |
|
ReceiverExported |
已过时.
标志 |
ReceiverNotExported |
已过时.
标志 |
ReceiverVisibleToInstantApps |
已过时.
标志 |
RestrictionsService |
使用 和 |
RoleService |
使用 和 |
SearchService |
使用 和 |
SensorService |
将 与 一起使用 |
ServiceInterface |
|
ShortcutService |
使用 和 |
StatusBarService |
使用 和 |
StopForegroundDetach |
已过时.
选择 |
StopForegroundLegacy |
的选择器 |
StopForegroundRemove |
已过时.
选择器 |
StorageService |
使用 和 |
StorageStatsService |
将 与 一起使用 |
SystemHealthService |
使用 和 |
TelecomService |
使用 和 |
TelephonyImsService |
将 与 一起使用 |
TelephonyService |
将 与 一起使用 |
TelephonySubscriptionService |
将 与 一起使用 |
TextClassificationService |
将 与 用于 |
TextServicesManagerService |
使用 和 |
TvInputService |
使用 和 |
TvInteractiveAppService |
使用 和 |
UiModeService |
将 与 一起使用 |
UsageStatsService |
将 与 一起使用 |
UsbService |
将 与 一起使用 |
UserService |
使用 和 |
VibratorManagerService |
使用 和 |
VibratorService |
使用 和 |
VirtualDeviceService |
使用 和 |
VpnManagementService |
使用 和 |
WallpaperService |
使用 与 |
WifiAwareService |
将 与 一起使用 |
WifiP2pService |
使用 和 |
WifiRttRangingService |
使用 和 |
WifiService |
使用 和 |
WindowService |
使用 和 |
属性
Application |
返回拥有此服务的应用程序。 (继承自 Service) |
ApplicationContext |
返回当前进程的单个全局 Application 对象的上下文。 (继承自 ContextWrapper) |
ApplicationInfo |
返回此上下文包的完整应用程序信息。 (继承自 ContextWrapper) |
Assets |
返回应用程序包的 AssetManager 实例。 (继承自 ContextWrapper) |
AttributionSource |
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。 (继承自 Context) |
AttributionTag |
可在复杂应用中使用归因,以逻辑方式分隔应用的各个部分。 (继承自 Context) |
BaseContext | (继承自 ContextWrapper) |
CacheDir |
返回文件系统上特定于应用程序的缓存目录的绝对路径。 (继承自 ContextWrapper) |
Class |
返回此 |
ClassLoader |
返回可用于检索此包中的类的类加载程序。 (继承自 ContextWrapper) |
CodeCacheDir |
返回专用于存储缓存代码的文件系统上特定于应用程序的缓存目录的绝对路径。 (继承自 ContextWrapper) |
ContentResolver |
返回应用程序包的 ContentResolver 实例。 (继承自 ContextWrapper) |
DataDir |
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。 (继承自 ContextWrapper) |
DeviceId |
获取与此上下文关联的设备 ID。 (继承自 Context) |
Display |
获取与此上下文关联的显示。 (继承自 Context) |
ExternalCacheDir |
返回主外部文件系统 (上的目录的绝对路径,该目录位于应用程序可以放置其拥有的缓存文件的某个位置 ExternalStorageDirectory 。 (继承自 ContextWrapper) |
FilesDir |
返回文件系统上存储使用 OpenFileOutput(String, FileCreationMode) 创建的文件的目录的绝对路径。 (继承自 ContextWrapper) |
ForegroundServiceType |
如果服务已通过调用成为前台服务 |
Fullscreen |
返回此梦是否处于全屏模式。 - 或 - 梦的窗口上的控件 |
Handle |
基础 Android 实例的句柄。 (继承自 Object) |
Interactive |
返回此梦是否是交互式的。 - 或 - 将此梦想标记为交互式以接收输入事件。 |
IsDeviceProtectedStorage |
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。 (继承自 ContextWrapper) |
IsRestricted |
指示此上下文是否受到限制。 (继承自 Context) |
IsUiContext |
|
JniIdentityHashCode |
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。 (继承自 Object) |
JniPeerMembers |
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。 |
MainExecutor |
返回一个 |
MainLooper |
返回当前进程的main线程的 Looper。 (继承自 ContextWrapper) |
NoBackupFilesDir |
返回文件系统上目录的绝对路径,类似于 FilesDir。 (继承自 ContextWrapper) |
ObbDir |
如果可以找到任何) ,则返回此应用程序的 OBB 文件 (的主外部存储目录。 (继承自 ContextWrapper) |
OpPackageName |
返回应该用于 |
PackageCodePath |
返回此上下文的主 Android 包的完整路径。 (继承自 ContextWrapper) |
PackageManager |
返回 PackageManager 实例以查找全局包信息。 (继承自 ContextWrapper) |
PackageName |
返回此应用程序包的名称。 (继承自 ContextWrapper) |
PackageResourcePath |
返回此上下文的主 Android 包的完整路径。 (继承自 ContextWrapper) |
Params |
返回创建此上下文时使用 的参数集(如果它是通过 |
PeerReference |
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。 (继承自 Object) |
Resources |
返回应用程序包的 Resources 实例。 (继承自 ContextWrapper) |
ScreenBright |
返回此梦是否在做梦时保持屏幕亮丽。 - 或 - 将这个梦想标记为在做梦时保持屏幕明亮。 |
Theme |
返回与此 Context 关联的 Theme 对象。 (继承自 ContextWrapper) |
ThresholdClass |
此 API 支持 Mono for Android 基础结构,不应直接从代码中使用。 |
ThresholdType |
此 API 支持 Mono for Android 基础结构,不应直接从代码中使用。 |
Wallpaper | (继承自 ContextWrapper) |
WallpaperDesiredMinimumHeight | (继承自 ContextWrapper) |
WallpaperDesiredMinimumWidth | (继承自 ContextWrapper) |
Window |
检索梦的当前 |
WindowManager |
检索梦中的当前 |
方法
显式接口实现
IJavaPeerable.Disposed() |
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。 (继承自 Object) |
IJavaPeerable.DisposeUnlessReferenced() |
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。 (继承自 Object) |
IJavaPeerable.Finalized() |
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。 (继承自 Object) |
IJavaPeerable.JniManagedPeerState |
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。 (继承自 Object) |
IJavaPeerable.SetJniIdentityHashCode(Int32) |
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。 (继承自 Object) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) |
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。 (继承自 Object) |
IJavaPeerable.SetPeerReference(JniObjectReference) |
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。 (继承自 Object) |
扩展方法
JavaCast<TResult>(IJavaObject) |
执行 Android 运行时检查的类型转换。 |
JavaCast<TResult>(IJavaObject) |
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。 |
GetJniTypeName(IJavaPeerable) |
扩展此类以实现用户可用的自定义梦想 (作为“Daydream”) 。 |