Showing posts with label #howto. Show all posts
Showing posts with label #howto. Show all posts

Monday, January 7, 2013

Connecting Android to Apache on localhost

Sometimes the requirements given to client/s are a bit odd especially when you are working as a freelance.  In my previous android projects, apps that requires internet permissions is as easy as what on the android documentation says.  Recently, I've got a project that uses internet to fetch updates.  The resources that I have are a site and a mysql database.  Now, I have to setup this site into local and run some tests on localhost.  In order for you to connect your android device to access localhost, make sure your laptop and android device are on the same wifi network.  You need to get the ip address of your localhost.  To do this, execute this command:

$ ifconfig

This is a utility used by system administrators to display and analyze network interface parameters.  Result should display like the image below.

The ip address of the laptop is at the wlan0 which is 192.168.1.35.  We may have different results depending on how many devices connected on wifi.  You may have something like 192.168.1.xx.  So on your test device, try changing the localhost to your ip address.

WebView webview = (WebView) findViewById(R.id.webview);
webview.setWebViewClient(new WebViewClient());
webview.loadUrl("http://192.168.1.35/drupal/");

Thanks to this post at StackOverflow.

Friday, September 21, 2012

USB Debugging on Samsung Galaxy Tab Using Ubuntu

If you are developing android applications using either the Samsung Galaxy Tab 7" or the 10.1", chances are you'll have a hard time using adb to these devices.  If you have followed these instructions in the android developer site and you find it working for you, then congratulations!  In my case, it's different.  Restarting the udev and adb doesn't work for me.  When I try the command adb devices, it shows,

$ adb devices
List of devices attached
????????????    device

and if I check the devices attached to my machine using lsusb it shows,

$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 003: ID 0a5c:21bc Broadcom Corp. BCM2070 Bluetooth 2.1 + EDR
Bus 001 Device 005: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II]

Samsung handles these attached devices differently.  I'm still not sure what causes this but it has something to do with the MTP (Mobile Transfer Protocol).  So what I did, I googled for answers and found this answer from stack exchange.  Thanks to this guy a.k.a Flow.  I guess this may work for you.  So go ahead and check his answer and don't forget to upvote it.

Tuesday, September 4, 2012

Is Unity3D Supported On Your Ubuntu?

One way to check if Unity3D is supported in your Ubuntu, open a terminal and type this command

$ /usr/lib/nux/unity_support_test -p

Result should tell if Unity3D is supported like the image below.


Do you have any tips on how to tell if you're on Unity3D?  Glad if you share.

Wednesday, August 29, 2012

Check CPU Information and Speed

To check CPU information and speed on your Ubuntu or any Linux distro, open the terminal and run this command:

$ cat /proc/cpuinfo

If you have other techniques and ways, please feel free to add it in the comments.

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.

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.