2016-04-06 18 views
3

İçinde bir hayal kurma özelliği olan bir uygulama geliştirmeye çalışıyorum. Aşağıdaki öğretici bahsediyorum:Özel android uygulamamda DayDream hizmeti başlatılamadı

http://www.technotalkative.com/how-to-create-daydream/

Altında Ayar> Ekran> DayDream, ben uygulamalar listesinde başvurumu görmek mümkün duyuyorum ama bunu başlatmaya çalıştığınızda hiçbir şey olmuyor. Neyin yanlış gittiğini anlayamıyorum.

<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> 

Sınıf dosyası::

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); 

    } 
} 

cevap

6

Sen hedefliyoruz api seviyesi 21 ve üzeri takiben

aynı, Manifest dosyası ile ilgili benim kodudur.

<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> 

: Sen Hafif uykuyu yerine getirmek için BIND_DREAM_SERVICE hizmet izni ayarlamak gerekir
İlgili konular