I was trying to install an Android app I wrote onto my phone, but I ran into an issue.

Eclipse wasn’t recognizing my (Verizon) Samsung Galaxy Nexus (Model #: SCH-I515MSAVZW) as a debugging device, so I had to install drivers for it. When I tried to install the drivers from Samsung’s website, though, I received this error: Continue reading →

I’ve started diving into MonoDroid a little bit, and I was following the directions here to create a ListView. The first step is to create a layout for each of the ListView items, which I followed, but the Resource.Designer.cs file was not updating with my newly created layout.

While developing with Android in Eclipse, the resources are auto-generated by just creating the files in the layout directory, which, evidently, is not the case for MonoDroid in Visual Studio. After searching a bit, I found this BuildProcess page for MonoDroid. It explained that resource files need the Build Action property of AndroidResource in order for the Resource.Designer.cs file to be updated with the layout.

Not sure if it’s possible to change the default, but out of the box the Build Action for an xml file is Content.

I do a lot of programming on a laptop without a mouse, and Eclipse shortcuts are imperative if I want to remain productive. Even when I do have a mouse, using keyboard shortcuts is usually faster than trying to click around for what I need. Here is a list of shortcuts that I use often.

If you have done any database work for Android by extending SQLiteOpenHelper, you have also had the experience of passing a Context down through the layers of your application to your database adapter. This is annoying because while you want the focus of your programming efforts to be on your application domain, part of your application design is focused on forwarding a framework-specific variable. Fortunately, roboguice comes to the rescue with just a few handfuls of code.

First, you’ll need to create an application class that inherits from RoboApplication:

public class MyApplication extends RoboApplication { }

RoboApplication contains the method protected void addApplicationModules(List<Module> modules) that you can override and add any modules that you’ve defined to the List, so you can add the following to your application class:

The last piece of the puzzle is for your Activities to extend from a Robo*Activity (RoboActivity, RoboListActivity, etc.) which will hook up the static injection:

public class MyActivity extends RoboActivity { }

Now, whenever an instance of the DBAdapter is created, roboguice will inject our current Context into contextProvider before calling the constructor:

DBAdapter dbAdapter = new DBAdapter();

Another way to inject a context provider into the DBAdapter is to use the usual guice injection strategy of creating an interface, implementing it, and configuring an AbstractModule. This approach requires more overhead, but perhaps creates a cleaner solution. I might write another post detailing this method if there’s interest.