Monday, July 30, 2012

Google App Engine

Google App Engine (GAE) lets you run web applications on Google infrastructure.  The good thing in this technology is that there's no need for you to maintain the server.  You can also use this technology as backend to your android applications (it means that this provides the data exchange between your android application, application server, and GCM).  You can run Java, Go, and Python environments for your web application environment.  This article will tackle Java and Android stuffs.  More of this stuff can be found here.

To send/receive JSON data for an Android application.
In this article, I use Eclipse on Ubuntu for the development.

Installation

Download the Google App Engine SDK for Java here.

In Eclipse, go to Help > Install New Software > Work With textbox, get the Eclipse update site url here.

Right after the installation, Google plugin is added in the Eclipse toolbar.

Now you can

Creating and Running a Web Application

To create a sample web application, click on the Google plugin then select 'New Web Application Project' and click 'Finish'. A sample Hello World code is provided in your new web application project.  To Run, hit on Run button, Run As > Web Application.  Check and see your browser.  Your web application project is hosted locally.  The url is http://localhost:8888.

Then deploy this project in GAE.  To deploy, click the Google plugin and click Deploy To App Engine > App Engine Project Settings > enter your ProjectId in the Application ID textbox > hit OK > Deploy

Once deployment is successful, you can see something like this image below.

Save logcat to a File

To save a logcat into a file, simply open the terminal and run this command

$ adb logcat -d > filename.txt

where filename.txt is any name you want.

Saturday, June 16, 2012

ADB Over Wifi

When you are doing android development and you don't have the usb adapter with you, there's a way to use adb by tweaking your device using adb over wifi.  To do this, your device must be rooted. I'm using CyanogenMod and this tweak is part of the features.  First, enable the ADB Over Wifi then restart the device.

Once restarted go to your Terminal Emulator.
$ su
# setprop service.adb.tcp.port 5555
# stop adbd
# start adbd

On your computer, 
$ adb connect 192.168.1.48:8000

The ip address on the example is the ip address of your device. If you don't know how to get the ip address of your device, here's a quick step.  Go to Settings > Wireless & Networks > Wifi Settings > select the network that you're connected to.

And you should be connected!  Now you can proceed with android development without worrying your usb adapter.


More detailed info here.

Wednesday, June 13, 2012

Setting Android Environment Variable

When debugging android applications, I always use the terminal to check the logcat but using it I still have to go to tools directory under android sdk.  It's very inconvenient for me since I cannot use the android commands in other directories.  By default, setting up the android sdk into Eclipse for the first time, ANDROID_HOME environment variable isn't setup by linux file system.  To setup,

open the terminal and edit the .bashrc file and add these lines at the end of the file:
ANDROID_HOME=/home/path_to_/android-sdk-linux
export ANDROID_HOME

and then append this to the current PATH
PATH=$PATH:$JAVA_HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export PATH

The tools and platform-tools directory are the most important here since they contain all the android-related commands.

Sunday, June 10, 2012

Add Workspaces in Unity 2D

In Lucid Lynx, I am used to work with 6 workspaces and each workspace has its own function.  One workspace for Chrome, one for Eclipse, one for the Terminal (logcat), one for the Android Emulator, and the other one for Pidgin.  I am an LTS user and I wasn't bothered by other releases (Maverick Meerkat, Natty Narwhal, Oneiric Ocelot) until when Precise Pangolin was released, the desktop was changed from GNOME to Unity interface.  Now I upgraded my Lynx to the new LTS Pangolin on both my desktop and laptop.

I experienced different issues on desktop and on my laptop with the Unity interface.  The first look into Unity from desktop and laptop puzzled me.  On desktop, I can change the size of the launcher to 32 and add more workspaces in it.  Glad I found MyUnity, a tweaking tool for Unity desktop.  On laptop, I see no options to change the launcher size.  MyUnity only works on Unity 3D.  Now this made me think that my laptop has Unity 2D.  Then I did my research and found this tweak.

On terminal:
$ wget http://webupd8.googlecode.com/files/script.py
$ chmod +x script.py
$ sudo ./script.py 32

The '32' changes your icon launcher size to minimum.  Now to add more workspaces to your Unity desktop, I also found this tweak.

On terminal, you have change thru gconf and run this command:
$ gconftool-2 -s -t integer /apps/metacity/general/num_workspaces 6

Restart your machine.

Do you have any alternatives?  Glad if you share.  Just add it in the comments.

Tuesday, May 22, 2012

Setup Multiple Devices for Android Development

I didn't find good resources in setting up multiple devices for android development.  When using Windows, if devices are plugged in via usb, it automatically installs the driver.  In Linux, it's different.  You have to do it manually.  Good example is in Android Developer page but this doesn't answer my problem. I have my LG device and 2 of our test devices at work (HTC and Samsung Galaxy Tab).  So I have to test it myself and here's what I did.

Go to rules.d directory
$ home_dir/etc/udev/rules.d


Create a file for each device
$ vim 51-android.rules
$ vim 61-android.rules
$ vim 71-android.rules

On the content, change the ATTR{idVendor} to specific USB Vendor IDs
For LG
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", GROUP="plugdev"

Lastly, change the file permission
chmod a+r /etc/udev/rules.d/51-android.rules

Restart udev
$ sudo restart udev

To check, use adb command.
android_sdk_dir$ ./adb devices
List of devices attached 
emulator-5554     device
HT115HL12346     device
46411929E53773CE    device
It should display the list of devices...


Do you have any other methods? Put it on the comments.

Tuesday, April 17, 2012

Hello World!


Toast.makeText(context, "Hello World", Toast.LENGTH_LONG).show();