Tag Archive : android

/ android

Using Stand Alone Android NDK Compiler

March 21, 2017 | Article | No Comments

Android is an operating system for various mobile device, such as mobile phone, tablet, smart TV, etc. The power of android comes from the use of a process virtual machine, dubbed as Dalvik Virtual Machine (DalvikVM) and later Android Run Time (ART), to abstract complicated and varying modules. You write in Java, compile it, and android environment will run it regardless of whatever hardware it has. It guarantees portability but for us. But if you want to write in native code, android provide us with NDK (Native Development Kit).

The product of NDK is a native code, which will be invoked by Android application (written in java) by JNI means.

There are three ways to use Android NDK as far as I know. This article will discuss all of them. But before it, we need to know some background information to let you know what happen behind the scene.

Obtaining NDK

NDK is free for download. You can download it from this official link.There are four platform available (Windows 32-bit, Windows 64-bit, Mac OS X, Linux 64-bit). Choose the one suitable for your platform. These packages are archived using zip. You can extract them with your favorite extractor / zip program and place it to any directory. Make sure they are invokable or can be called from command line. You can achieve this by setting the environment variable or PATH in your respective platform.

If the directory is mentioned, we will refer it as $NDK.

Target Platform

Android has came to various platform. ARM/ARM64, x86/x86-64, MIPS/MIPS64. Your mobile device platform is your target so you need to know and make sure what platform you face. In most case, ARM is sufficient as it is currently dominating the mobile system’s market. But again, make sure you know the platform. You can achieve it by reading the datasheet or information provided by the manufacturer.

Android NDK use GCC infrastructure. So for the platform you chose it will have the triplet which indicating the platform. You can verify it here.

[table “10” not found /]

The toolchain is located at $NDK/toolchains

Sysroot and Target API

Sysroot is a directory containing the system headers and libraries for target. To define sysroot we must know the Android API level we want to target. The Android API levels reside under $NDK/platforms/. Fortunately, unlike SDK, android has shipped all the supported API level so downloading the current NDK is recommended.

Building

Way 1: Use Makefile

In GNU world we know Makefile. Makefile is a small script that is used by “make” command to automatically configure and build the application. It can be thought as a configuration script. It is declarative so we need only declare some parts, such as include directory, sources file, and output then we invoke the makefile to automatically build it without needed to compile each file by yourself.

In android, we have Android.mk and Application.mk for this purpose. The Android.mk file is useful for defining and overriding project-wide settings. It must resides in our project’s $PROJECT/jni/ directory, and describes sources and libraries we use. The Application.mk is placed under directory of $NDK/apps/ directory.

For example we have these files

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := foo
LOCAL_SRC_FILES := foo.c

include $(BUILD_EXECUTABLE)

APP_ABI: armeabi armeabi-v7a

Then we can invoke the build process as this.

ndk-build

The NDK will give output such as this when build is in process.

[armeabi] Compile thumb  : foo <= foo.c
[armeabi] Executable     : foo
[armeabi] Install        : foo => libs/armeabi/foo
[armeabi-v7a] Compile thumb  : foo <= foo.c
[armeabi-v7a] Executable     : foo
[armeabi-v7a] Install        : foo => libs/armeabi-v7a/foo

Way 2: Use compiler Directly

Know the platform we face and it’s API level. To use this way, we need to define the sysroot. The specific invokation will depend on your OS, but generally we need to define a SYSROOT variable which point to our sysroot and then invoking the compiler.

Use this code for example.

int main()
{
   return 0;
}

Windows

Set these once before compiling.

SET SYSROOT=%NDK%\platforms\android-22\arch-arm
SET TPATH=%NDK%\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin
SET CC=%TPATH%\arm-linux-androideabi-gcc.exe --sysroot=%SYSROOT%

and use this for compiling

%CC% -o code.o code.c

Linux

Set these once before compiling.

export SYSROOT=$NDK/platforms/android-22/arch-arm
export TPATH=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin
export CC=$TPATH/arm-linux-androideabi-gcc --sysroot=$SYSROOT

and use this for compiling

$CC -o code.o code.c

Mac OS X

Set these once before compiling.

export SYSROOT=$NDK/platforms/android-22/arch-arm
export TPATH=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin
export CC=$TPATH/arm-linux-androideabi-gcc --sysroot=$SYSROOT

and use this for compiling

$CC -o code.o code.c

Way 3: Use Customized Toolchain

NDK provides a wrapper. This is useful if we want to invoke command without necessary using ndk-build. The make-standalone-toolchain.sh script is provided to perform a customiezed toolchain installation from command line. The script is located in $NDK/build/tools/ and unfortunately no windows’ .bat version available.

To use it, we can invoke this command:

$NDK/build/tools/make-standalone-toolchain.sh --arch=arm --platform=android-22 --install-dir=/tmp/my-android-toolchain

The wrapper is created in /tmp/my-android/toolchain/ which contain copy of android-22/arch-arm sysroot and the toolchain binaries for 32-bit ARM architecture. This wrapper doesn’t depend on host so we can place it in any location or even move it to any location.

To invoke the wrapper

export PATH=/tmp/my-android-toolchain/bin:$PATH
export CC=arm-linux-androideabi-gcc
export CXX=arm-linux-androideabi-g++

and use it as usual.

A common misconception about developing for the Google Android Platform is that you have to write your code in the Java programming language. The truth is you actually have many options. OK, aside of NDK (Native Development Kit) using C/C++, you can develop application using Scripting Layer for Android.

The Scripting Layer for Android (SL4A) brings scripting language to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device. Started out as 20% project by Google employee Damon Kohler, the project now supports Python, Ruby, Perl, Lua, JavaScript, BeanShell, and more platform.

This article is part of series of articles explores how to use Python and Scripting Layer for Android (SL4A) to build application for Android.

This article will discuss about how to setup environment for developing Android app using Python. What I use for this article are:

  1. Slackware64 14.0 as developer machine
  2. Windows 8 64-bit as developer machine
  3. Sony XPeria U as target machine
  4. Java Development Kit (JDK) 1.7.0_13
  5. Android Software Development Kit (SDK)
  6. Python 2.7.3

Note that I use Slackware (Linux) and Windows as proof of concept. You can either use one or both but I will try to make it as general as possible.

Who have Use SL4A?

Many! But notable users are:

  1. SmallSat
  2. Cellbots – http://www.cellbots.com/
  3. Oplop – http://code.google.com/p/oplop/
  4. Broadcast – http://github.com/mleone/broadcast/

Why Python?

So the first question, why python?

Python is a great tool for writing both simple scripts and complex, multi-threaded applications. The great thing about having Python on Android is the opportunity to use the untold thousands of lines of code already written and freely available. Python is an easy language to learn if you’ve never used it before, and you will find many resources available on the Internet to help get you up to speed.

Obtain Materials

SL4A has several packages. But for our goal, we need only two packages: core SL4A and Python for android. Both you can download from SL4A download site.

Here what you need (last version per September 26th, 2013):

  1. sl4a_r6.apk
  2. PythonForAndroid_r4.apk

As the popularity of Python for Android grow, the project has been forked to new project which stand side to SL4A. You can visit Python for Android project page and download their latest release.

If you don’t have Oracle JDK, Android SDK, and Python yet then grab them.

Installation and Setup

On Android Device

Install SL4A on Android device. This process is similar to any other Android application installation process.

Before installation, make sure you enable the “Unknown sources” option in your device’s “Application” settings.

screenshot_2013-09-26_1215

Open up terminal / your command prompt. Make sure you can access adb from your “$ANDROIDSDK/platform-tools” path.

Connect your phone to your machine and invoke following commands:

adb install -r sl4a_r6.apk
adb install -r PythonForAndroid_r4.apk

To make sure Python for Android installed, see your application list and search for Python for Android. It should has following user interface:

screenshot_2013-09-26_1241

Tap on Install to install the interpreter needed. Your phone then downloading some extra packages.

To verify, open application named SL4A on your launcher. See the “Interpreter” on “View” menu. You should see Python 2.6.2 there.

screenshot_2013-09-26_1305

On Development Machine

The SL4A needs Oracle Java Development Kit (JDK) and Android Software Development Kit (SDK). All of them must be provided before we install SL4A. We also need to install Python. Note that all dependencies should have correct architecture based on your machine. As I use 64-bit machine, I will need to install the 64-bit version.

At this point, I assume you have all the dependencies installed.

Reference:
  1. Installing Android SDK on Linux
  2. Installing Android SDK on Windows
  3. Installing Java Development Kit on Linux

Testing

Let’s test the environment by creating a simple hello world project.

Write this on your development machine as hello.py:

import android
droid = android.Android()
result = droid.makeToast('Hello, world!')

Then send it to your Android phone. The simplest way is using adb.

adb push hello.py /sdcard/sl4a/scripts/hello.py

Now run the script by running SL4A. You should see lot of python script in the list. Our script is hello.py, just tap it to run it and you can see the toast.

You can also create a simple script to upload your script:

Appendix A: SL4A Functionality

The SL4A has following functionality which can be used on Python:

  • ActivityResult
  • Android
  • ApplicationManager
  • BatteryManager
  • Camera
  • CommonIntents
  • Contacts
  • Event
  • EyerFree
  • Location
  • MediaPlayer
  • MediaRecorder
  • Phone
  • Preferences
  • SensorManager
  • Settings
  • Sms
  • SpeechRecognition
  • ToneGenerator
  • WakeLock
  • Wifi
  • UI

This article will give a short summary of what should be known when developing Android application.

Table of Contents

  1. Android Insight
  2. Architecture
  3. Security and Permissions
  4. Conventions and API Level
  5. Development Tools
  6. Android Developer Tools
  7. Android Application Component
  8. Resources and Important Files

Android Insight

The Android Operating System

Android is a operating system based on Linux Operating System. The project is lead by Google with a consortium of Open Handset Alliance.

Nowadays, Android is used as some of smartphones and tablets operating system. Moreover, there is a project to port Android to x86 (a common PC). Android is a major player in smartphone OS beside Windows Phone, iOS, etc.

Android system supports background processing, provides a rich user interface library, supports 2-D and 3-D graphics using OpenGL libraries, access to the file system and embedded SQLite database.

Platform Component

Android system is a full software stack which is typically defined into the following four areas:

  1. Applications – The Android Open Source project contains several default application, like the Browser, Camera, Gallery, Music, Phone and more.
  2. Application framework – API which allow for high-level interaction with the Android system from Android applications.
  3. Libraries and runtime – Libraries for the Application Framework for many functions (graphic rendering, data storage, web browsing, etc.) and the Dalvik runtime and the core Java libraries for running Android applications.
  4. Linux kernel – Communication layer for the underlying hardware.

androidsoftwarelayer10

How to Develop Android Applications

Android applications are primarily written in the Java programming language.

During development the developer creates the Android specific configuration files and writes the application logic in the Java programming language. The Java source files are converted to Java class files by the Java compiler.

The Android SDK contains a tool called dx which converts Java class files into a .dex (Dalvik Executable) file. All class files of one application are placed in one compressed .dex file. During this conversion process redundant information in the class files are optimized in the .dex file. For example if the same String is found in different class files, the .dex file contains only one reference of this String.

These .dex files are therefore much smaller in size than the corresponding class files.

The .dex file and the resources of an Android project, e.g. the images and XML files, are packed into an .apk (Android Package) file. The program aapt (Android Asset Packaging Tool) performs this packaging.

The resulting .apk file contains all necessary data to run the Android application and can be deployed to an Android device via the adb tool.

The ADT and Android Studio tools perform these steps transparently to the user, i.e. if the user selects that the application should be deployed, the whole Android application (.apk file) is created, deployed and started.

Architecture

The architecture discussed in this section is the architecture of Android. Android can be referred as software stack of different layer, where each layer is a group of several program components. These levels define abstraction on device and provide same API for application on above.

Android-architecture

Linux Kernel

The kernel space. This area is controlled directly by Linux kernel and the basic layer of Android OS.

The whole Android OS is built on top of the Linux 2.6 Kernel with some further architectural changes made by Google. It is this Linux that interacts with the hardware and contains all the essential hardware drivers. Drivers are programs that control and communicate with the hardware. For example, consider the Bluetooth function. All devices has a Bluetooth hardware in it. Therefore the kernel must include a Bluetooth driver to communicate with the Bluetooth hardware. The Linux kernel also acts as an abstraction layer between the hardware and other software layers. Android uses the Linux for all its core functionality such as Memory management, process management, networking, security settings etc. As the Android is built on a most popular and proven foundation, it made the porting of Android to variety of hardware, a relatively painless task.

Libraries

Android Native Libraries layer is the layer that enables the device to handle different types of data. This libraries are written in C or C++ language and are specific for a particular hardware.

Some important libraries:

Surface Manager: It is used for compositing window manager with off-screen buffering. Off-screen buffering means you cant directly draw into the screen, but your drawings go to the off-screen buffer. There it is combined with other drawings and form the final screen the user will see. This off screen buffer is the reason behind the transparency of windows.

Media framework: Media framework provides different media codecs allowing the recording and playback of different media formats

SQLite: SQLite is the database engine used in android for data storage purposes

WebKit: It is the browser engine used to display HTML content

OpenGL: Used to render 2D or 3D graphics content to the screen

Runtime

Consists of Dalvik Virtual Machine and Core Java Libraries.

Android use a special virtual machine, i.e. the Dalvik Virtual Machine to run java based application. It is similar to standard Java Virtual Machine (JVM) however using stripped down and optimized one. The bytecode between Dalvik is also different from Java bytecode.

Thus, you cannot run Java class files on Android directly. They need to get converted to Dalvik bytecode format.

These are different from Java SE and Java ME libraries. However these libraries provides most of the functionalities defined in the Java SE libraries.

Application Framework

These are the blocks that our applications directly interacts with. These programs manage the basic functions of phone like resource management, voice call management etc. As a developer, you just consider these are some basic tools with which we are building our applications.

Important blocks of Application framework are:

Activity Manager: Manages the activity life cycle of applications

Content Providers: Manage the data sharing between applications

Telephony Manager: Manages all voice calls. We use telephony manager if we want to access voice calls in our application.

Location Manager: Location management, using GPS or cell tower

Resource Manager: Manage the various types of resources we use in our Application

Application

The top layer, also referred as user space. In this layer, our application will reside and run.

Security and Permissions

Security Concept

The Android system installs every Android application with a unique user and group ID. Each application file is private to this generated user, e.g. other applications cannot access these files. In addition each Android application is started in its own process.

Therefore, by means of the underlying Linux operating system, every Android application is isolated from other running applications.

If data should be shared, the application must do this explicitly, e.g. via a service or a content provider.

Permission Concept

Android contains a permission system and predefines permissions for certain tasks. Every application can request required permissions and also define new permissions. For example an application may declare that it requires access to the Internet.

Permissions have different levels. Some permissions are automatically granted by the Android system, some are automatically rejected. In most cases the requested permissions are presented to the user before the installation of the application. The user needs to decide if these permissions are given to the application.

If the user denies a required permission, the related application cannot be installed. The check of the permission is only performed during installation, permissions cannot be denied or granted after the installation.

An Android application declares its required permissions in its AndroidManifest.xml configuration file. It can also define additional permissions which it can use to restrict access to certain components.

Conventions and API Level

API Version

API Level is an integer value that uniquely identifies the framework API revision offered by a version of Android platform.

The Android platform provides a framework API that applications can use to interact with the underlying Android system. The framework API consists of:

  • A core set of packages and classes
  • A set of XML elements and attributes for declaring a manifest file
  • A set of XML elements and attributes for declaring and accessing resources
  • A set of Intents
  • A set of permissions that applications can request, as well as permission enforcements included in the system

Each successive version of the Android platform can include updates to the Android application framework API that it delivers.

Updates to the framework API are designed so that the new API remains compatible with earlier versions of the API. That is, most changes in the API are additive and introduce new or replacement functionality. As parts of the API are upgraded, the older replaced parts are deprecated but are not removed, so that existing applications can still use them. In a very small number of cases, parts of the API may be modified or removed, although typically such changes are only needed to ensure API robustness and application or system security. All other API parts from earlier revisions are carried forward without modification.

Android Project and Package Name

The base package for the projects is always the same as the project name, e.g. if you are asked to create a project called com.vogella.android, then the corresponding package name is com.vogella.android.

The application name, which must be entered on the Android project generation wizard, is not always predefined. In this case choose a name you like.

Development Tools

Android SDK

Software Development Kit (SDK) is a collection of tools and source code necessary to create, compile, and package a certain application. Thus, Android SDK is a SDK to create, compile, and package an application for Android. Most of these tools are command line. The primary language used at SDK is Java programming language.

The Android SDK contains Android debug bridge (adb), a tool which allows us to connect to a virtual or even real android. Using this, we can manage the device and debugging application.

Android NDK

Native Development Kit (NDK) or Android NDK, is similar to Android SDK. Android NDK is targeted to expert in C\C++ who want to explore more into lower level.

The primary language used at NDK is C\C++ programming language.

Android Developer Tools and Android Studio

For developing an Android application, Google has provided graphical development environment. There are two flaovrs you can choose: Eclipse and IntelliJ IDE. Using Eclipse IDE, it means we should install a plugin so the Android developing process can be done. This is called Android Development Tool (ADT). The counterparts using IntelliJ IDE and has been tweaked to fulfill the duty. It’s called Android Stutio.

The Android Developer Tools (ADT) are based on the Eclipse IDE and provide additional functionalities to develop Android applications. ADT is a set of components (plug-ins) which extend the Eclipse IDE with Android development capabilities.

Both tools contain all required functionalities to create, compile, debug and deploy Android applications from the IDE. They also allow the developer to create and start Android virtual devices for testing.

Both tools provide specialized editors for Android specific files. Most of Android configuration files are based on XML. In this case these editors allow you to switch between the XML representation of the file and a structured user interface for entering the data.

Android Developer Tools

Eclipse provides a perspective for interacting with Android Virtual Device and your Android application program. This is included on everytime you install plugin for Eclipse.

DDMS – Dalvik Debug Monitor Service

Select Window → Open Perspective → Other… → DDMS to open this perspective. It groups several Eclipse views which can also be used independently.

On the left side it shows you the connected Android devices and the running processes on the device. The right side is a stack of views with different purposes. You can select processes and trigger actions from the toolbar, e.g. start a trace or stop the process.

Emulator Control

Simulate phone calls and SMS on the AVD. It also allows the application to set the current geo position.

File Explorer

Browse the filesystem on Android Virtual Device.

Android Application Components

Android applications can consists out of four components:

  • Activities
  • Services
  • Broadcast receivers
  • Content provider

Activities

An activity represents the visual representation of an Android application. An Android application can have several activities.

Activities use views and fragments to create the user interface and to interact with the user. Both elements are described in the next sections.

Services

A service performs tasks without providing an user interface. They can communicate with other Android components for example via broadcast receivers and notify the user via the notification framework in Android.

Broadcast Receivers

A broadcast receiver (receiver) can be registered to receive system messages and intents. A receiver gets notified by the Android system, if the specified event occurs.

For example you can register a receiver for the event that the Android system finished the boot process. Or you can register for the event that the state of the phone changes, e.g. someone is calling.

Content Provider

A content provider (provider) provides a structured interface to application data. A provider can be used for accessing data within one application but can also be used to share data with other applications.

Android contains an SQLite database which is frequently used in conjunction with a content provider. The SQLite database would store the data, which would be accessed via the provider.

Resources and Important Files

Android Manifest File

The components and settings of an Android application are described in the AndroidManifest.xml file. This file is known as the Android manifest file.

All activities, services and content providers components of the application must be statically declared in this file. Broadcast receiver can be defined statically in the manifest file or dynamically at runtime in the application.

The Android manifest file must also contain the required permissions for the application. For example if the application requires network access it must be specified here.

Following is the example of Android Manifest File:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="de.vogella.android.temperature"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Convert"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="9" />

</manifest>

The package attribute defines the base package for the Java objects referred to in this file. If a Java object lies within a different package, it must be declared with the full qualified package name.

Google Play requires that every Android application uses its own unique package. Therefore it is a good habit to use your reverse domain name as package name. This will avoid collisions with other Android applications.

android:versionName and android:versionCode specify the version of your application. versionName is what the user sees and can be any String.

versionCode must be an integer. The Android Market determine based on the versionCode, if it should perform an update of the applications for the existing installations. You typically start with “1” and increase this value by one, if you roll-out a new version of your application.

The <activity> tag defines an activity component. The name attribute points to class, which (if not fully qualified), is relative to the package defined in the package attribute.

The intent filter part in the Android manifest file, tells the Android runtime that this activity should to registered as possible entry point into the application and made available in the launcher of the Android system. The action define that is can be started android:name="android.intent.action.MAIN" ) and the category android:name="android.intent.category.LAUNCHER" category tells the Android system to add the activity to the launcher.

The @string/app_name value refers to resource files which contain the actual value of the application name. The usage of resource file makes it easy to provide different resources, e.g. strings, colors, icons, for different devices and makes it easy to translate applications.

The uses-sdk part of the AndroidManifest.xml file defines the minimal SDK version for which your application is valid. This will prevent your application being installed on unsupported devices.

Resources Files

Android supports that resources, like images and certain XML configuration files, can be keep separate from the source code.

Resource files must be placed in the /res directory in a predefined sub-folder dependent on their type. You can also append additional qualifiers to the folder name to indicate that the related resources should be used for special configurations. For example you can specify that layout file is only valid for a certain screen size.

Resource IDs and R.java

Every resource file gets an ID assigned by the Android build system. The gen directory in an Android project contains the R.java references file which contains these generated values. These references are static integer values.

If you add a new resource file, the corresponding reference is automatically created in R.java file. Manual changes in the R.java file are not necessary and are overridden by the tooling.

The Android system provides methods to access the corresponding resource files via these IDs.

For example to access a String with the R.string.yourString ID in your source code, you would use the getString(R.string.yourString)) method.

Deployment

In general, you can use several method to deploy an application to your device. Those are by USB transfer, email the application, use Google Play, etc. The following sections will highlights the most common ones and common deployment process.

There is also a specific article discussing this material. You can check it on this link.

Deployment via Eclipse

Turn on USB Debugging on your device in the settings. Select in the settings of your device Applications → Development, then enable USB debugging.

You may also need to install the a driver for your mobile phone. Linux and Mac OS usually work out of the box while an Windows OS typically requires the installation of a driver.

Please note that the Android version you are developing for must be the installed version on your phone.

If you have only one device connected and no emulator running, the Android develoment tools will automatically deploy to this device. If you have several connected you can selected which one shoudl be used.

Export Application

Android application must be signed before they can get installed on an Android device. During development Eclipse signs your application automatically with a debug key.

If you want to install your application without the Eclipse IDE you can right-click on it and select Android Tools → Export Signed Application Package.

This wizard allows to use an existing key or to create a new one.

Please note that you need to use the same signature key in Google Play (Google Market) to update your application. If you loose the key you will NOT be able to update your application ever again.

Make sure to backup your key.

Via External Source

Android allow to install applications also directly. Just click on a link which points to an .apk file, e.g. in an email attachment or on a webpage. Android will prompt you if you want to install this application.

This requires a setting on the Android device which allows the installation of non-market application. Typically this setting can be found under the “Security” settings.

Google Play

Google Play requires a one time fee, currently 25 Dollar. After that the developer can directly upload his application and the required icons, under Google Play Publishing .

Google performs some automatic scanning of applications, but no approval process is in place. All application, which do not contain malware, will be published. Usually a few minutes after upload, the application is available.

Turn Android Smartphone to IP Web Camera

December 9, 2015 | Article | No Comments

Android Operating System is one of popular operating system for mobile device (smartphone, tablets, etc) beside Windows Phone, Apple iOS, etc.

This article will discuss about how to use our android smartphone as a IP Webcam (web camera). There are many reasons to do so, for example: you don’t have much budget to install complex CCTV system but need to have a simple one at home. You just need an android smartphone with camera (well, it would be rare if we see smartphone without camera) and connect it to the internet.

For a summary, this is what I use in this article:

  1. Sony XPeria U
  2. Windows 8 64-bit
  3. IP Webcam app (download from Google Play on your smartphone)

Remember that the list above is the one I have used.

Base Theory

In this method, we turn our smartphone into an IP Camera. Our phone will act as a camera and connect to internet. As any device connected to internet, it has some IP assigned. Using that IP, we can open and see the display given by phone remotely.

Summary, your phone will do a video streaming through net. WATCH OUT THE DATA TRAFFIC !!

Preparation

You phone and your PC should be at the same network, otherwise it won’t work. You can connect both device using same wifi router.

Make sure your network has IP address between 10.0.0.1 to 10.255.255.255 as the application will likely bound to that range IP address.

On Phone Side

Download IP Webcam on Google Play.

Make sure your phone ins connected to internet

There are lot of configuration available on IP Webcam. You can configure the video resolution, orientation, connection settings, etc. For simplicity, we use default configuration.

Start the Server once you have done configuring.

You will got your phone camera and a IP address at the bottom. Write down this IP address.

On PC Side

Make sure your computer is connected to internet.

Using IP address you got from your phone, open a web browser and enter following address:

http://IP:8080/videofeed

Where IP is the IP you got and 8080 is port opened at your phone.

Useful Note

Better resolution means better quality. However this also means bigger data transferred from your phone. If data traffic is expensive for you, you can always decrease the quality in configuration.

Android Application Development using Windows

December 9, 2015 | Article | No Comments

There are also version of this article for Linux Ubuntu and Linux Slackware64.

Android Operating System is one of popular operating system for mobile device beside Windows mobile, Apple iOS, etc. This article main focus would be concentrated on installation of development tools, which is Eclipse IDE, Android SDK, and Android Developer Tool on Windows 8 64-bit.

Why Eclipse? Eclipse is an open source Integrated Development Environment and has full support for Android. It’s also quite simple.

In the time i write this article, I use Windows 8 64-bit.This article will focus on Windows  8, though you can use this method and apply it to other Windows version. You must also have active internet connection to do installation and fetching required packages.

You can skip some part if you are confident enough that you have done it before. Well, but nothing wrong by read a whole article, right? 😉

Now let’s we go!

Preparation

We need to install JAVA and Eclipse. But running Eclipse need JAVA so we will install JAVA first.

When using 64-bit machine, make sure you have JAVA and Eclipse for same architecture. It means, you cannot have Eclipse 64-bit and using JAVA 32-bit. It goes same for 32-bit Eclipse and 32-bit JAVA.

At this point, I assume you have install JAVA and Eclipse.

Installation

Android Developer Tool Plugin

Now let’s moving to installation of Androit Developer Tool (ADT). It is a special Eclipse plugin contains integrated android environment for building Android application using eclipse.

Start eclipse. Now navigate to:

Help - Install New Software - Add

enter the following information:

Name: ADT Plugin
Location: https://dl-ssl.google.com/android/eclipse/

Click on OK. Now select “Developer Tools” and/or “NDK Plugins”. Click Next to begin installation. Wait for installation to finish its work.

Install the SDK

Next we will install Android SDK. Downlad Android SDK starter pack from this link

Download the latest SDK. By the time I write this article, the latest version is 22.0.5. It is an installer with filename installer_r22.0.5-windows.exe.

Run the installer file and choose a path for installing SDK. In my case I will leave the SDK on C:\Program Files (x86)\Android\android-sdk

Install SDK Platforms

Now we need to install platforms and optional additional plugins or sample codes. Start SDK manager (If you just do install the Android SDK, you will be asked to start the SDK):

C:\Program Files (x86)\Android\android-sdk\SDK Manager.exe

Seleck SDK Platforms you want. I choose Android 2.3.3 API 10 as my smartphone Sony Xperia U use this one. When you have selected all packages you want, click Install Selected. You will be prompted to Accept License. Click Accept All and then Install.

Create Android Virtual Device

Now we have to join Eclipse IDE with Android SDK and create and Android Virtual Device (AVD). Android Virtual Device is an emulator to run your application on top of your computer.

In Eclipse, navigate to:

Window - Preferences - Android

Enter location of your Android SDK installation. In my case it is in C:\Program Files (x86)\Android\android-sdk. Press OK.

Now navigate to:

Window - Android Virtual Device Manager - New

Insert following information into:

AVD Name: AndroidVirtualDevice
Device: <your preferred device>
Target: <chose any desired Android version and API level available>

Click OK. The new Android Virtual Device will be created in the directory:

C:\Users\<your username>\.android\avd

Congratulations! Now you can develop android apps on Windows!

Installing Android 4.0 in VirtualBox

December 5, 2015 | Article | No Comments

Android, the popular Operating System for smartphones, now come in handy on PC. Some folks at Android-x86 project had port this little Green Buddy into PC. And thanks to them, we can enjoy the Android on our PC.

In this article, we will discuss about Android x86 installation on VirtualBox. For this, I use:

  1. Slackware64 14.0, although any Operating System is fine at least it can run VirtualBox
  2. VirtualBox.
  3. Android x86 ISO file

Obtaining the Materials

As said, we will do installation of Android on virtual machine using VirtualBox. Thus you have to make sure VirtualBox is installed and enable to run properly. For Slackware64, I have create a separated article about how to install VirtualBox on Slackware.

Another material we need is the Android x86 ISO itself. The ISO is provided by http://www.android-x86.org, the official site. The project had made many builds of Android OS for a quite. You can see many version with many architecture supported by them. The one we use is android x86 4.0 RC2 for asus laptop.

For some version provided there, they don’t work very well in VirtualBox. For example the “EEEPC” image for Android 4.0 has issues with the audio drivers and the network (it has no Ethernet support built in), etc. But fortunately, There is an ISO image which has been custom made to match with VirtualBox which I found on another people site. Although he said this is not his made, but thanks Kirsle! You can download the ISO from this site!

Create the Virtual Machine

Now come to the main business. Create a new machine for Android with this (minimum) specification:

  • Machine Name: “Android x86 ICS” (or anyname you want)
  • Machine Type: “Linux
  • Machine Version: “Linux 2.6”
  • Memory: 256 MB (but I use 1024 MB)
  • Hard disk: 12 GB (12 GB is enough, but mine is 16 GB)

Other setting on my Virtual Machine:

  • Networking:
    • Type: NAT
    • Adaptor: “Intel Pro/1000 MT Desktop (8254EM)”
  • Audio: Intel AC’97
  • Storage Layout:
    • IDE Controller: CD Device
    • SATA Controller: Hard disk
  • Video Memory: 16 MB

Boot and Install

Run the virtual machine, you should then see something similar to this:

android1

If you want to try the live CD, you can choose “Live CD – VESA mode” on boot menu. You will then see the screen like this:

android3

Another screenshot for Android x86 4.0:

android2

If you decide to install it, in boot menu (you should restart the machine if you are on Live CD mode) choose “Installation – install Android-x86 to harddisk”. Then you will see bunch of text on console and then be brought to partition menu. OK, get ready.

In this article we will use all the space we have and create only partition. You can also create more than one partition, but we won’t cover that here.

Choose “Create/Modify Partitions” which leads you into cfdisk. To do so do the following:

  1. Choose “[New]”
  2. Choose “[Primary]”
  3. Press enter to accept the default partition size
  4. Choose “[Bootable]”
  5. Choose “[Write]”
  6. Type “yes” to confirm writing
  7. Choose “[Quit]”

Now choose to install on the “sda1 device Linux VBOX HARDDISK”. Format it to “ext3”. Confirm “yes” on formatting. Confirm “yes” when it asks to install GRUB bootloader. Confirm “yes” when it asks to mount /system as read-write.

Now create a fake SD card when it prompts. I made 2074MB (the maximum allowed).

Reboot! Make sure you detach the ISO image from the virtual machine and boot the installed OS. If you still see “Installation” option again, then you are booting form ISO.

Disable Mouse Integration

To interact with GUI, you need to disable mouse integration. This can be done by choosing the “Machine” menu in the VM window and clicking “Disable Mouse Integration”. Another way is pressing HostKey + I.

For an article about Android Application Development using Linux Ubuntu, you can visit here

Android Operating System is one of popular operating system for mobile device beside Windows mobile, Apple iOS, etc. This article main focus would be concentrated on installation of development tools, which is Eclipse IDE, Android SDK, and Android Developer Tool on slackware 64 bit.

Why Eclipse? Eclipse is an open source Integrated Development Environment and has full support for Android. It’s also quite simple.

In the time i write this article, I use Slackware64 14.0. Of course you can use other linux distribution if you like. You must also have active internet connection to do installation and fetching required packages.

You can skip some part if you are confident enough that you have done it before. Well, but nothing wrong by read a whole article, right? 😉

Now let’s we go!

Preparation

We need to install JAVA and Eclipse. But running Eclipse need JAVA so we will install JAVA first. An article for installing latest JAVA for Slackware64 can be found here. An article for installing latest Eclipse for Slackware64 can be found here.

Our machine is 64-bit but some tools are 32-bit. Therefore we need to make sure our Slackware is multilib enabled.

Installation

Android Developer Tool Plugin

Now let’s moving to installation of Androit Developer Tool (ADT). It is a special Eclipse plugin contains integrated android environment for building Android application using eclipse.

Start eclipse. Now navigate to:

Help - Install New Software - Add

enter the following information:

Name: ADT Plugin
Location: https://dl-ssl.google.com/android/eclipse/

Click on OK. Now select “Developer Tools” and/or “NDK Plugins”. Click Next to begin installation. Wait for installation to finish its work.

Install the SDK

Next we will install Android SDK. Downlad Android SDK starter pack from this link

Download the latest SDK. By the time I write this article, the latest version is 21.0.1. You can download linux version directly in this link:

Extract the content of Android SDK pack:

tar -xvzf android-sdk_r21.0.1-linux.tgz

In my case I will leave the SDK on /home/xathrya/android-sdk.

But wait! If you read it, you will notice that the SDK is for linux 32 bit. Our Slackware is 64 bit, right? Don’t worry, this article will guide you to convert your Slackware64 to be multilib-enabled a.k.a capable of running 32 bit application.

Install SDK Platforms

Now we need to install platforms and optional additional plugins or sample codes. Start SDK manager:

/home/xathrya/android-sdk/tools/android

Seleck SDK Platforms you want. I choose Android 2.3.3 API 10 as my smartphone Sony Xperia U use this one. When you have selected all packages you want, click Install Selected. You will be prompted to Accept License. Click Accept All and then Install.

Create Android Virtual Device

Now we have to join Eclipse IDE with Android SDK and create and Android Virtual Device (AVD). Android Virtual Device is an emulator to run your application on top of your computer.

In Eclipse, navigate to:

Window - Preferences - Android

Enter location of your Android SDK installation. In my case it is in /home/xathrya/android-sdk/. Press OK.

Now navigate to:

Window - Android Virtual Device Manager - New

Insert following information into:

AVD Name: AndroidVirtualDevice
Device: <your preferred device>
Target: <chose any desired Android version and API level available>

Click OK. The new Android Virtual Device will be created in the directory:

~/.android/avd

Congratulations! Now you can develop android apps on Slackware!

Other Notes

If you had previously install Eclipse CDT and can’t install Android SDK, please refer here.

Android Operating System is one of popular operating system for mobile device beside Windows Phone, Apple iOS, etc. The popularity comes from the fact that Android is open source, used by various vendor. You have a freedom to modify and do anything to your Android, though you will void your warranty.

This article main focus would be concentrated on installation of development tools, which is Eclipse IDE, Android SDK, and Android Developer Tool.

Why Eclipse? Eclipse is an open source Integrated Development Environment and has full support for Android. It’s also quite simple.

In the time i write this article, I use GNU/Linux Ubuntu 10.10. Of course you can use other linux distribution if you like, especially Debian or Ubuntu derivative distribution. I might encourage you to use later version if possible. You must also have active internet connection to do installation and fetching required packages.

Table of Content

  1. Installation
    1. Eclipse IDE
    2. Oracle Java JDK
    3. Android Developer Tool Plugin
    4. SDK and SDK Platform
  2. Create Android Virtual Device

Installation

[x] Installing Eclipse IDE

First, installing Eclipse. In this article I will use latest Eclipse (per September 6th, 2012) version. It’s Eclipse 4.2 Juno for Linux 32 bit. You can download it at this link.

I pick eclipse-SDK-4.2-linux-gtk.tar.gz, it is a ready to use version means no installation required. Download it and then extract the file.

tar xvzf eclipse-SDK-4.2-linux-gtk.tar.gz

We will have a new extracted directory named eclipse. Move this directory to /opt. This is a good practice for FHS (Filesystem Hierarchy Standard) as an optional software installed to this. In my case I extracted eclipse in /home/xathrya/Downloads. I will invoke following command and remember the command need privileges as /opt is usually owned by root:

mv /home/xathrya/Downloads/eclipse  /opt

Create symbolic link to eclipse in /usr/bin (use root privilege):

ln -s /opt/eclipse/eclipse /usr/bin/eclipse

[x] Installing Oracle Java (Replace OpenJDK)

You can use OpenJDK and skip this. However if you want

Next you must have a running JAVA Runtime Environment. We need to install Oracle Java. Ubuntu has come with a default OpenJDK Environment so we will replace it.

In Ubuntu, the JAVA is located on repository partner which indicated it is a proprietary repository. To install JAVA first we have to add the repository. In this case I use maverick meerkat (Ubuntu 10.10 distribution), if you have other distribution, you can replace maverick with your Ubuntu codename (ex: lucid for lucid lynx, natty for natty narwhal)

sudo add-apt-repository "deb http://archive.canonical.com/ maverick partner"
sudo apt-get update

After that you can install JAVA JRE

sudo apt-get install sun-java6-jre galternatives

last we need to change the default java environment for OpenJDK to Sun JRE 6

sudo galternatives

Select java in left panel and select java-6-sun as shown by image below:

Now, verify your java installation. Invoke this command:

java -version

This should gives you message like this:

java version "1.6.0.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Client VM (build 17.1-b03, moxed mode,sharing)

[x] Android Developer Tool Plugin

Now let’s moving to installation of Androit Developer Tool (ADT). It is a special Eclipse plugin contains integrated android environment for building Android application using eclipse. Reminder: my eclipse version is 4.2 (Juno)

Start eclipse. Now navigate to:

Help - Install New Software - Add

enter the following information:

Name: ADT Plugin
Location: https://dl-ssl.google.com/android/eclipse/

Click on OK. Now select “Developer Tools” and/or “NDK Plugins”. Click Next to begin installation. Wait for installation to finish its work. With my connection around 50KB/s the installation done in 30 minutes.

[x] Install the SDK and SDK Platform

Next we will install Android SDK. Downlad Android SDK starter pack from this link

Download the latest SDK. By the time I write this article, the latest version is 20.0.3. You can download linux version directly in this link:

Extract the content of Android SDK pack:

tar xvzf android-sdk_r20.0.3-linux.tgz

In my case I will leave the SDK on /home/xathrya/android-sdk.

Now we need to install platforms and optional additional plugins or sample codes. Start SDK manager:

/home/xathrya/android-sdk/tools/android

Seleck SDK Platforms you want. I choose Android 2.3.3 API 10 as my smartphone Sony Xperia U use this one. When you have selected all packages you want, click Install Selected. You will be prompted to Accept License. Click Accept All and then Install.

Create Android Virtual Device

Now we have to join Eclipse IDE with Android SDK and create and Android Virtual Device (AVD). Android Virtual Device is an emulator to run your application on top of your computer.

In Eclipse, navigate to: Window -> Preferences -> Android

Enter location of your Android SDK installation. In my case it is in /home/xathrya/android-sdk/. Press OK.

Now navigate to Window -> AVD Manager -> New

Insert following information into:

Name: AndroidVirtualDevice
Target: [chose any desired Android version and API level available]

Click Create AVD. The new Android Virtual Device will be created in the directory:

~/.android/avd

We are done!

Social media & sharing icons powered by UltimatelySocial