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

Android Gestures

Since version 1.6 Android offers a library for recognition and handling of new gestures using a touch display. With the gesture builder it is possible to capture new gestures in the emulator. Gestures can be integrated into an activity like that. GestureLibrary gLib = GestureLibraries.fromRawResource(this, R.raw.spells); if (!gLib.load()) { finish(); } Furthermore we need a gesture overlay in the UI: <android.gesture.GestureOverlayView android:id="@+id/gestures" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1.0" /> In the next step we implement an event handler for the gesture (Source: http://developer.android.com/resources/articles/gestures.html): GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures); gestures.addOnGesturePerformedListener(this); public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) { ArrayList<prediction> predictions = mLibrary.recognize(gesture); if (predictions.size() > 0) { Prediction prediction = predictions.get(0); if (prediction.score > 1.0) { Toast.makeText(this, prediction.name, Toast.LENGTH_SHORT).show(); } } } ...

May 21, 2010 · 1 min · 197 words · Micha Kops

Signing APK with the Maven-Jar-Signer Plugin

There is a nice Maven plugin helping you signing your Android app – the Maven Jar Signer Plugin. If you want to learn more about Maven integration in an android project take a look at this article. Maven Profile Setup Add the following code to your pom.xml <?xml version="1.0"?> <profiles> <profile> <id>sign</id> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jarsigner-plugin</artifactId> <version>1.2</version> <executions> <execution> <id>signing</id> <goals> <goal>sign</goal> </goals> <phase>package</phase> <inherited>true</inherited> <configuration> <archiveDirectory/> <includes> <include>target/*.apk</include> </includes> <keystore>path/to/keystore</keystore> <storepass>storepasword</storepass> <keypass>keypassword</keypass> <alias>key-alias</alias> </configuration> </execution> </executions> </plugin> <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>maven-android-plugin</artifactId> <inherited>true</inherited> <configuration> <sign> <debug>false</debug> </sign> </configuration> </plugin> </plugins> </build> </profile> </profiles> ...

April 17, 2010 · 1 min · 155 words · Micha Kops