Using the Android Daydream API

Daydream is the new interactive screensaver mode that was added in the Android 4.2 / Jelly Beans release. Such “dreams” may be activated when the device is in idle mode or inserted into a dock. In the following tutorial we’re going to create a simple daydream that starts a simple animation and in addition we’ll be adding a configuration screen to alter the behaviour of this daydream. Create a new Android Application First of all we need a new android project. I am using Eclipse and the ADT plugin here but any other solution like using a specific Maven archetype and the Jayway Maven plugin or using SBT should work, too. ...

January 22, 2013 · 6 min · 1097 words · Micha Kops

Task Scheduling in Java EE 6 on GlassFish using the Timer Service

Creating cronjobs or scheduled service executions is made really easy in Java EE 6. Scheduled tasks may be created in a programmatic style or simply by adding some annotations to an EJB. In the following tutorial we’re creating some simple scheduled tasks and let them run on an embedded GlassFish instance using the Maven Embedded GlassFish plugin.. Java EE 6 Maven Project from Archetype First of all we’re creating a new maven-ized project using one of the appropriate jee6 Maven archetypes ...

June 22, 2012 · 5 min · 956 words · Micha Kops

Wiring made easy using OSGi Blueprint and Apache Karaf

The OSGi Blueprint Container specification allows us to use dependency injection in our OSGi environment, declarative import and export of OSGi services, registering lifecycle listeners and wiring dependencies into our services with a few lines of XML code. In the following tutorial we’re first building an OSGi bundle classical style and afterwards take a trip into the advantages of the Blueprint specification. Our OSGi container of choice here will be Apache Karaf a lightweight container with a lot of nice features and – of course – blueprint enabled… ...

April 16, 2012 · 9 min · 1705 words · Micha Kops

Managing Background Tasks on Android using the Alarm Manager

In today’s tutorial we’re going to take a look on how to handle periodically scheduled tasks on our Android device by using BroadcastReceivers, Services and the AlarmManager. Prerequisites The following environment is needed to follow this tutorial … Java Development Kit 6 Android SDK An AVM with at least Android 2.2 / API Version 8 I recommend using Eclipse with the ADT Plugin installed The Concept We’re going to create a first broadcast receiver that gets initiated at boot time. This component then should make use of Android’s AlarmManager API and schedule a cyclic task using an explicit intent. ...

November 27, 2011 · 4 min · 666 words · Micha Kops

Android Widget Tutorial: Creating a screen-lock Widget in a few steps

In today’s Android tutorial we’re going to take a look at Android’s Widget API and how to make a widget interact with a service using intents. Figure 1. hasCode Android Widget Tutorial Logo We’re going to create a fully functional application that allows us to enable or disable our smartphone’s screen lock settings using a widget that can be placed on our home screen. Finally, I am going to show how to use a smartphone to test and debug our application and connect it to the IDE. ...

October 6, 2011 · 10 min · 2082 words · Micha Kops

REST-assured vs Jersey-Test-Framework: Testing your RESTful Web-Services

Today we’re going to take a look at two specific frameworks that enables you to efficiently test your REST-ful services: On the one side there is the framework REST-assured that offers a nice DSL-like syntax to create well readable tests – on the other side there is the Jersey-Test-Framework that offers a nice execution environment and is built upon the JAX-RS reference implementation, Jersey. In the following tutorial we’re going to create a simple REST service first and then implement integration tests for this service using both frameworks. ...

September 5, 2011 · 6 min · 1094 words · Micha Kops

Kubernetes Snippets

Rerun existing completed Job kubectl replace deletes the old job, if there is any error, your job definition is lost, don’t forget to save it first! Replace an existing Job with itself kubectl get job JOBNAME -o yaml | kubectl replace --force -f - Sometimes there are errors importing the job template due to auto-generated labels or selectors .. a quick and dirty hack is to filter them out using jq ...

March 1, 2010 · 10 min · 1924 words · Micha Kops