Setting up Eclipse for Android development

Curious to see what the Android platform has to offer, I decided to try out some basic app development with it.

What you need:
  • Android SDK
  • Java SDK (JDK)
  • Eclipse

What I got: (for this tutorial)

File Setup:
I put all my files in a common folder, just to make things easier to find.
You can put them anywhere else, just remember to adjust the pathnames in this tutorial accordingly.

Create a folder "D:\Android" and extract the contents of both "android-sdk-windows-1.1_r1.zip" and "eclipse-SDK-3.4.2-win32.zip" into it.

Then create a folder "D:\Android\workspace" to save your Eclipse projects.

The folder should now contain 3 folders:
  • D:\Android\android-sdk-windows-1.1_r1\
  • D:\Android\eclipse\
  • D:\Android\workspace\

Installing ADT Plugin for Eclipse:

Starting up "D:\Android\eclipse\eclipse.exe" will load the Eclipse IDE.
When Eclipse asks you what workspace to load up, select "D:\Android\workspace".

(optional)
Click "Use this as the default and do not ask again" if you don't plan on changing your workspace.

Once its done loading, close the welcome screen.

Go to "Help -> Software Updates -> Available Software -> Add Site".
Paste in https://dl-ssl.google.com/android/eclipse (or http://dl-ssl.google.com/android/eclipse if the other site isn't working).
Expand the new Android node and wait for it to fetch some information.
Once it loads, select "Developer Tools" and click the "Install" button.
This will take a while to finish.
Restart Eclipse when prompted.

Configuring ADT Plugin:
Once its done reloading, there is one last step in configuring Eclipse before its ready for use.
Go to "Windows -> Preferences -> Android -> Browse".
Select "D:\Android\android-sdk-windows-1.1_r1" and click OK.

You are now ready to develop with the Android platform.



Testing:
To test out your setup, right click on the package explorer and select "New -> Project"
Select "Android -> Android Project" and click "Next".

Since its easier to test with some existing code, we're going to use the sample project "LunarLander".
Click on "Create project from existing source" and then click "Browse".
Select "D:\Android\android-sdk-windows-1.1_r1\samples\LunarLander" and click "Finish".

Go to "Run -> Debug -> Android Application".

The emulator should start up and display "A N D R O I D _" on a black screen for a few moments. It'll take a little bit longer to load up the Android OS, but eventually the LunarLander application should start up.

Enjoy!

Best online portfolio/resume EVER!

http://noahstokes.com

hahaha so awesome I dont know what to say.

Can't change directory to another drive in DOS Command Prompt

I'm not sure when Microsoft decided to change this syntax, but I am quite certain back in the old days of DOS I was able to type this "cd D:\games\mmx" and it'd work!

Sometime last year I noticed that I could no longer do this on the XP command prompt window. Its been nerfed. Why? I do not know.

At first I thought it was because I was using it via a remote desktop session and thought nothing of it (apart from being annoying).

Just today, I realised it also affected my local sessions also. So off I went to discover a way to fix it.

Typing in "cd /?", I found this.
CD [/D] [drive:][path]
Type CD drive: to display the current directory in the specified drive.

Use the /D switch to change current drive in addition to changing current directory for a drive.
I tried it and it worked.
What the hell?
C:\Documents and Settings\twig>cd d:
D:\

C:\Documents and Settings\twig>cd /d d:

D:\>
So I guess now we have to use the new syntax to change drives using "cd".
How annoying.

Batch renaming files on Linux

I had a bunch of PNG files which had both upper-case and lower-case extensions.

Trying to rename them in Windows was painful as I needed to rename it to a temporary extension, commit, then rename back and commit again.

I found a handy script to use in the command line of Linux, and since it supported case-sensitive filenames, all I had to do was rename and commit.
for file in *.PNG ; do svn mv $file `echo $file | sed 's/\(.*\.\)PNG/\1png/'` ; done
Worked like a charm!

Secret Australian Internet Censorship Blacklist Leaked

Site is currently down, probably due to a massive influx of traffic.

http://wikileaks.org/wiki/Australian_government_secret_ACMA_internet_censorship_blacklist,_6_Aug_2008

Take a peek at it when you can, it'd be likely that the government is gonna try to block it somehow IF the filters go up.

Put that web filtering money into something more useful, like schools or into the police force.

FUCK THE ACMA!
Thanks, but no thanks.

*edit*
Just found a copy of the blacklisted links, probably copied from the wiki leak site.
Download it! And as the description says, share it before it gets taken down!

Offline documentation for Mootools

There are alot of times when I need documentation while working on something but don't have internet connectivity, such as when I'm on a train.

Previously, I have been using a CHM file for MooTools v1.11 and it was great! I also found docs for v1.2.0 and settled with that, which was quite sufficient for what I was doing.

Scouring the net over and over for months yeilded little results when trying to find docs for the latest MooTools v1.2.1.

But alas, I needed to stop relying on others so much. I needed to know how to generate my own!

Thanks to some help from Aaron Newton from ClientCide, I've managed to get started on the documentation generation.

Once the code was cleaned up, I quickly got the documentation to output files rather than to a browser.

It was tricky trying to get the files to point to each other, rather than use the markdown style defined for the server such as "/Native/Hash".

After a day of tinkering with the output, I've managed to generate the MooTools v1.2.1 documentation for offline use!

I've posted the files up on SourceForge (set up by Tux).
- documentation for v1.2.1. (07/03/2009)
- documentation for v1.2.3. (05/07/2009)
- documentation for v1.2.4. (27/12/2009)
- documentation generator (last updated 27/12/2009)

Hopefully this technique will also work for future MooTools releases.

The SourceForge project page is at http://sourceforge.net/projects/mootoolsdocgen

Retrieve deleted Thunderbird messages

If your email is still in the Trash folder, then simply view it.
The rest of this post will be irrelevant to you.

However, sometimes you delete from the trash and realise later "oh shit! I needed that!"

To retrieve a deleted email from Thunderbird, you've gotta pray that you haven't compacted your data files since the email was deleted.

Next, go to your "Account Settings" in Thunderbird and view the "Server Settings" for your account.
Copy the "Local directory" path and view in Windows Explorer.
Note:
If you have more than one email configured to one hostname, you might have to do some snooping around to figure out which one is the right folder.
Close Thunderbird and make a backup copy of your files before modifications.

If you remember the name of the folder which the email was in (usually Trash), then simply open the "Trash" in Notepad (not Trash.msf).

Search for the email somehow (ie. the sender address, email title, some content fragments, read throug it all, etc).

When you find it, look for the "X-Mozilla-Status" for the email you wish to retrieve.
Normally the value is "0x0009", meaning "Read" (MSG_FLAG_READ) and "Expunged" (MSG_FLAG_EXPUNGED).
Change the value to "0x0000" and save.

Load up Thunderbird and view the Trash. Hopefully the email should be visible again.

[ Source ]

Fix: VMWare slow to release swapped memory after stopping guest

Ever since upgrading to VMWare v6.5.1, I've noticed it would take several minutes for my laptop to respond to input after closing VMware or pausing/shutting down a guest.

The excessive harddrive activity would halt my host operating system and prevent hibernation from working (causing me to nearly miss my train station several times!)

Luckily, someone's found the solution to fixing this problem by setting some hidden configuration options.

Open up your "guest.vmx" file in Notepad and paste the following lines at the end of the file.
mainMem.useNamedFile = "FALSE"
prefvmx.useRecommendedLockedMemSize = "TRUE"
prefvmx.minVmMemPct = "100"
This has stopped the excessive harddrive activity on my laptop and I have been able to get off the train on time =)

[ Source ]

For more configuration options, see this link.

Using Drupal API in your website

(If you're looking for a way to bootstrap your automated/scheduled scripts, then look here. This guide is for bootstrapping Drupal to pages loaded by your browser.)

As this is written for Drupal 6.8, instructions may vary for other versions (5.x, 7.x, etc).

Download Drupal and extract files into /path/to/website/drupal

1. Installation
Install Drupal by visiting http://domain/drupal/install.php in your browser.
Ensure no table name conflicts with existing site (ie. any tables named "users", "files" or "access")

2. Bootstrapping the Drupal API
[ source ]
This allows full access to Drupal API from without your website.

The following code is a modified version of ceejayoz's script bootstrap code.

/**
* Allows us access into Drupal's API.
*/
function initialise_drupal_bootstrap() {
// Determine Drupal's directory
$DRUPALINC = realpath('./drupal');

// Adjust PHP's include path so Drupal properly includes it's dependencies
$paths = explode(';', get_include_path());
$paths[] = realpath('./');
$paths[] = $DRUPALINC;
set_include_path(implode(';', $paths));

// Save current working directory
$cwd = getcwd();
chdir($DRUPALINC);

// Call Drupal's bootstrapping code
require_once('includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

// restore error reporting to its normal setting
error_reporting(E_ALL);
}

Whenever you need to enable the Drupal API on a page, simply call initialise_drupal_bootstrap().

3. Edit .htaccess
This step is optional for Linux users, as you can simply create a symlink to the paths required.

Copy "/path/to/website/drupal/.htaccess" to "/path/to/website/" and open it up in a text editor.
Uncomment the line with "RewriteBase" and set it to "RewriteBase /drupal"

4. Test
  • Open your main page, it should show your original site. (ie. http://www.domain.com)
  • Attempt to access a Drupal rendered page, such as your user profile page at "http://www.domain.com/user"
  • View the Drupal main page, at "http://www.domain.com/drupal"

5. Configure
Log in as the administrator and view the page "http://www.domain.com/admin/settings/site-information" to set up your default front page.
 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog