Saturday, September 17, 2011

Testing internal C# methods in Visual Studio Express

Just add the following to AssemblyInfo.cs in the project under test:

   [assembly: InternalsVisibleTo("NameOfTestProject")]

Saturday, September 10, 2011

Building Android with Ant and External Libraries

Android seems set up by default to look in a folder called libs for libraries, so just drop your jars in there and it should just work!

Friday, September 2, 2011

Android Process Monitor

I have an app which needs to monitor whether another app is running or not. I used the following code:

    List runningAppProcessInfos =
((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getRunningAppProcesses();

and search the List of RunningAppProcessInfos for the process in question, after filtering out the running services. It works perfectly, except when a search for the process in question coincides with plugging the device into a usb charger (laptop in this case). For some reason, this code fails; the process I am interested in never stops running according to logcat, but it seems to be missing from the List as my app doesn't find it, so exits (part of the logic, not a crash).

Oh well, one to look out for...