Friday 21 December 2012

Android DayDreams

Hi,

This is my First post.Please encourage me to continue this forever.

Well, So my First post is about Android. 


Android used to keep so many attractive sweet names in Alphabetical order that starts from Cupcake(1.5) to JellyBean. Hope next new version of Android on march or may 2013 will be Android 5.0 Key Lime Pie.

Android released Jelly Bean 4.1,However 4.2  updates with minor changes also released. Several new concepts introduced in that. I get attracted on a concept called as Daydreams which I want to share with you.

Daydream is a new interactive screensaver mode for Android devices.It is added in api level 17.



Lifecyle of DreamService:

onAttachedToWindow():

Use this for initial setup, such as calling setContentView().

onDreamingStarted():
Your dream has started, so you should begin animations or other behaviors here.

onDreamingStopped()
Use this to stop the things you started in onDreamingStarted().

onDetachedFromWindow()
Use this to dismantle resources your dream set up. For example, detach from handlers and listeners.

Now Let us look a simple example for DayDreams.

//It extends with DreamService

public class DayEx extends DreamService 
{
//create a textview

TextView t;

//Based on lifecycle of daydreams, u need to use setcontentview in this method.
@Override
public void onAttachedToWindow() 
{

setContentView(R.layout.main);

t=(TextView)findViewById(R.id.textView1);

super.onAttachedToWindow();
 setInteractive(true);
 
      setFullscreen(true);
   
    t.setText("Hello world");

}

@Override
public void onDreamingStarted() {
// TODO Auto-generated method stub
super.onDreamingStarted();
}


}

In Android Manifest.xml declare this.


   <service
     android:name=".DayEx"
     android:exported="true"
     android:label="DayEx >

     <intent-filter>
        <action android:name="android.service.dreams.DreamService" />
        <category android:name="android.intent.category.DEFAULT" />
     </intent-filter>


Start to run the application.

Go to Settings-> Applications->Display->DayEx(The given service label will be displayed in this.You can change any name for the application).





You can display this while  in charging or in docked.You can select your choice in WHEN TO DREAM. Then select start now..



Enjoy..:) :)







No comments:

Post a Comment