2016-04-06 5 views
3

空白の機能が組み込まれているアプリを開発しようとしています。私は、次のチュートリアルを参照しています:私のカスタムアンドロイドアプリでDayDreamサービスを開始できません

http://www.technotalkative.com/how-to-create-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); 

    } 
} 

答えて

6

あなたが目標としている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> 

:あなたはあなたの空想を満たすために BIND_DREAM_SERVICEサービスのアクセス許可を設定する必要があります
関連する問題