[英]Clicking on settings button in Android Daydream service stopping the application
[英]Android: DayDream in Application
我正在開發我正在使用DreamService的應用程序。 但是內置選項只能在充電和對接時開始做白日夢。 是否有任何解決方案在執行應用程序期間調用白日夢(而設備暫時不活動,比如5秒)?
答案遲了一年,並沒有解決5秒問題的不活動,但仍然可能有用......
將以下DreamNow.java文件添加到項目中,並使用DreamNow類擴展Activity。
import android.app.Activity; import android.content.Intent; /** * To use, replace "extends Activity" in your activity with "extends DreamNow". * * From the Google Android Blog Daydream example. */ public class DreamNow extends Activity { @Override public void onStart() { super.onStart(); final Intent intent = new Intent(Intent.ACTION_MAIN); try { // Somnabulator is undocumented--may be removed in a future version... intent.setClassName("com.android.systemui", "com.android.systemui.Somnambulator"); startActivity(intent); finish(); } catch (Exception e) { /* Do nothing */ } } }
當DreamService
從Service
繼承時,應該可以使用startService動態啟動它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.