Layar tutorial part 2

SDK Version: 

The first tutorial, we went through the steps to create a simple layer.
In this tutorial, we are going to explain how to include actions in this layer

Multitouch and gesture detection part 2

SDK Version: 

In my previous article I showed how to create a simple class that handles the basic gesture events such as ACTION_DOWN, ACTION_MOVE, ACTION_POINTER_DOWN, ACTION_POINTER_UP, ACTION_UP. Combinations of these, you can implement all of touch gesture stuffs thats you need in your work with a touch screen phone.

Handling multitouch
Create a boolean member variable in your MultitouchView class that stores the actual multitouch event. Name it isMultiTouch.

  1. public class MultitouchView extends View {
  2.         private boolean isMultiTouch = false;
  3.  {...}

Multitouch and gesture detection part 1

SDK Version: 

In this little tutorial I’m going to show you how to detect multitouch event on an Activity screen.

First of all let’s create a class next to the Main activity that called MultitouchView. It extends View:

  1. public class MultitouchView extends View {
  5.         public MultitouchView(Context context) {
  6.                 super(context);
  8.         }
  10. }

How to build with Android NDK

SDK Version: 
The Android NDK is a companion tool to the Android SDK that lets you build performance-critical portions of your apps in native code. If you write native code, your applications are still packaged into an .apk file and they still run inside of a virtual machine on the device. The fundamental Android application model does not change.
First thing to do:
Go to http://developer.android.com/sdk/ndk/index.html and download Android NDK.
Okay, now you unzip the downloaded NDK zip to your hard disk drive.

If you are a windows user, you also have to have Cygwin, go to http://www.cygwin.com/ and download the latest version.
Install it, and run it, you should see a "linux-like" console.

Root your phone without using an usb cable

SDK Version: 

A few weeks ago ztomi had a tutorial about ADB wireless. You propably already have your favourite way of rooting your phone (superoneclick etc), but what if you don't want or can't use the usb port of your phone?

Calling system settings from an Android app - GPS example

SDK Version: 
This tutorial shows how to redirect the user to a system settings screen asking to modify some settings the application depends on. We will make a specific example with GPS: The application can be used only if GPS is available.

The android systems GPS setting screen can be called just like any other Activities:

  1. startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);

To check GPS availability use the code code below: (the Activity must implement LocationListener)

Using an Android phone's sensors

SDK Version: 

Accessing the sensor data of a phone, is not too complicated, but since API level 3, a lot of things got deprecated. Using only the emulator, you have only a few (here is one) options, to simulate sensor data. I would recommend the use of a physical phone. Keep in mind, that not all phones have the same sensors integrated! Cheaper phones might not have a temperature sensor, or a gyroscope, but I'm pretty sure, that all Android phones have at least an accelerometer, and an orientation sensor.

Here is an example, how to access acceleration and orientation sensor data (in API level 3 and above), without using any deprecated methods.

Syndicate content