Code Amnesia context sensitive code search

Code Amnesia looks like a really interesting project.

It allows you to search online for code snippets from within your IDE. The cool thing is that the search is context sensitive. It takes into account the code you are currently editing, which means it can merge the selected snippet into your code.

I don’t think I could use it much in my current work. But, if I was working as a consultant, often working on new projects that used different frameworks, I can see this being a real time and sanity saver.

This is a fairly new project, and only supports Intellij IDEA at the moment. It will be interesting to see what it leads too.

Android on Intellij Idea – run activity on emulator

The official Android plugin is only for Eclipse, but thankfully Android provides Ant support for those of us who prefer other IDEs (http://developer.android.com/guide/developing/other-ide.html).

I use Intellij IDEA, and the main problem for me was that, after building the application using the Ant build script created by activitycreator tool, you have to manually reload the application in the emulator.

This is easily fixed by tweaking the generated Ant build file.
Add the following target to the build.xml –

 <!-- Main activity -->
<property name="main-activity" value="MyMainActivity" />

 <!-- Run the main Activity after reinstall -->
 <target name="run" depends="reinstall">
 <echo>Running ${application-package}.${main-activity} on default emulator...</echo>
 <exec executable="${adb}" failonerror="true">
 <arg value="shell" />
 <arg value="am" />
 <arg value="start" />
 <arg value="-a" />
 <arg value="android.intent.action.MAIN" />
 <arg value="-n" />
 <arg value="${application-package}/${application-package}.${main-activity}" />
 </exec>
 </target>

MyMainActivity is, of course, your main activity. Remember to change the build file if you rename or change the main activity.

I also changed the default target to run, and after loading build.xml as an Ant build file in IDEA, I assigned it a shortcut key.
I also made these changes to ANDROID_SDK/tools/lib/build.template, so from now on, when I create a new Android project, it is already set up this way. If you are editing the template file, use –

 <!-- Main activity -->
<property name="main-activity" value="ACTIVITY_NAME" />

This will automatically pick up the class name you specify on the command line when running activitycreator.