Posts

Showing posts with the label daydream

Android Daydream with Processing.js

Image
How to create an Android Daydream with processing.js I've spent some time working out how to get processing.js (a nice javascript graphics library ported from Processing ) to display an Android Daydream (basically a screensaver that activates when the device is docked or charging) I previously wrote about how to display an HTML page as a Daydream which forms the basis for this post.  Please see my earlier post for full details but to summarise you can load an HTML page in a webview like this webView.loadUrl("file:///android_asset/www/index.html"); Processing.js allows you to display Processing code as javascript in a page, so all you need to do is either embed the processing.js code or load the Processing PDE file containing the code as explained on the processing.js site I only had a couple of issues with it which were: 1. The js code seemed to run at a much  higher frame rate than my native Processing code such that my animation looked insane . In the end I...

Creating an Android Jelly Bean Daydream from a WebView

Image
One of the new nifty features on Android Jelly Bean 4.2 is the concept of daydreams (basically a screensaver but also displays when docked etc).  I wanted to create one that displayed an HTML page, which makes for prety easy development and this is how First of all, this assumes you have API 17 (Android 4.2) installed, otherwise you won't have access to the relevant Android class Android Daydream option You need to create a new class that extends android.service.dreams.DreamService and override the onAttachedToWindow() method which is what is called when the service starts up.  In here all you really need to do is create a new WebView as normal and attach it.  Example code below import android.annotation.TargetApi; import android.service.dreams.DreamService; import android.webkit.WebView; @TargetApi(17) public class MyDreamService extends DreamService {   @Override   public void onAttachedToWindow() {     super.onAttachedToWindow(); ...