Friday, April 18, 2014

How to Access LocalHost on an Android Emulator

Last time I wrote about how to access LocalHost for Android phones. As it turns out, accesssing LocalHost on emulators are also different.

To access LocalHost point your device to 10.0.2.2:[PORT NUMBER].

Enjoy testing your app on the emulator.

Saturday, April 12, 2014

Using AWS SDK For Android

If you want to implement file upload to AWS S3 as part of your Android app here are some tips to get you going.

Setup

  1. Download the Android-AWS SDK
  2. Unzip the downloaded package then go to the lib folder
  3. In the lib folder copy aws-android-sdk-[version]-core.jar and aws-android-sdk-[version]-s3.jar
  4. Use the mechanism your IDE has provided add these jar files and make it available in code. (For Android Studio 0.5.4, I manually added it to the app > lib folder and right clicked on the jar files and select Make Module

Coding


// Create a new S3Client with your credentials. You could get the Keys from the IAM console.
AmazonS3Client s3Client =
new AmazonS3Client(new BasicAWSCredentials("ACCESS KEY", "SECRET KEY");

// Create a PutObjectRequest. This is used to communicate with AWS and upload your file
// The KEY is the full file path to where your file should be stored on AWS.
// For example, images/category/subcategory/image_name.jpg
// The FILE is a file object that you want to upload
PutObjectRequest putObjectRequest = new PutObjectRequest("BUCKET", "KEY", "FILE");

// Now tell AWS S3 a that you want to upload an image with the specifications above.
s3Client.putObject(putObjectRequest);

Tuesday, April 8, 2014

Setup A Superuser Account With Password On A Postgres Database

I program on Ruby on Rails and when you start off you could use SQLite as the local database, which doesn't require any setup to get things up and running. However, when your application becomes more complicated you should use a production level database such as Postgres locally to make sure production behaviors mirrors local behaviors. 

Here are the commands to setup an account with password and superuser rights.

CREATE ROLE [role_name] WITH LOGIN PASSWORD '[password]';
ALTER ROLE [role_name] SUPERUSER;

Friday, April 4, 2014

How To Do The Secret Handshake For Enabling Developer Mode On A Samsung Galaxy S4

To my surprise, enabling developer mode on a Samsung Galaxy S4 is extremely difficult, so difficult even developers such as myself couldn't figure it out. Samsung or Android must be really not trust their users.

Any who, below are the steps to the secret handshake
  1. Go to Settings > About device
  2. Scroll down to Build number
  3. Tap on Build number (a message should appear saying tap 3 more times to enable developer mode).
  4. Tap Build number 3 more times.
There you go developer mode has been enabled. Welcome to the club.

Thursday, April 3, 2014

Android Development Setup Instructions Using Eclipse 4.3.2 Kepler and ADT Plugin

Setting up Eclipse 4.3.2 Kepler for Android development using the ADT plugin is not a smooth process. Below are instructions on how to get it to work. Feel free to share this guide with your other Android developer friends to save them some time.

Step 1

Go to https://www.eclipse.org/downloads/ and download Eclipse Standard. Unpackage the zip folder you download and move it the Applications folder.



Step 2

After starting up Eclipse go to Help > Install New Software. Then an Available Software dialogue box will show up.



Step 3

Click on the Add button and the Add Repository dialogue will show up. For the name enter ADT Plugin and for location enter https://dl.google.com/eclipse/plugin/4.3

After you are done restart Eclipse.




Then you will realize that there are few more configurations that needs to be made. (1) Point to the correct location of Andriod SDK and (2) Update the JRE version to at least 1.7.0.



Step 4

Let's first point Eclipse to the correct location of the Android SDK by clicking on Open Preferences. Next click on the Browse button.


When the Finder opens type into search opt, click on the opt folder that contains the tools folder, and click open.




Step 5

Then a warning dialogue will show up saying the SDK Platform Tools component is missing with the Open SDK Manager button. Click on that button.


When the SDK Manager is open check off Tools and Android 4.4.2 (or the latest version) and click the Install button.

Before proceeding to install, you are prompted to accept all the license agreements for the software you are about to install.



Keep going until you wrap up the Android SDK installation.



Step 6

Now let's update the computer's JRE by going to Oracle's website.

Click on Download Java Platform (JDK) 8, accept any license agreement, unpackage the download, and run the installer.





There you are! You have finally finish installing the Android Development Tools (ADT) plugin for Eclipse 4.3.2 Kepler and you could finally start programming your Android app!