Full details here:
http://mobilebytes.wordpress.com/2010/06/30/classes-source-for-eclipse/
This site tells you the names of the tags for checking out particular versions:
http://grepcode.com/snapshot/repository.grepcode.com/java/ext/com.google.android/android/1.6_r2/
This may also be useful:
http://android.opensourceror.org/2010/01/18/android-source/
Sunday, November 13, 2011
Sunday, October 2, 2011
Android Asset Folder
There seems to be a limit to the size of file you can read from if it placed in the assets folder in Android. Trying to read bytes from a file over 1MB results in an IOException.
Stackoverflow suggests splitting files into 1MB chunks (or giving the file an extension such as .mp3 - i.e. already compressed), and that the problem is due to Android compressing files in the assets folder when they're above a certain size.
Stackoverflow suggests splitting files into 1MB chunks (or giving the file an extension such as .mp3 - i.e. already compressed), and that the problem is due to Android compressing files in the assets folder when they're above a certain size.
Saturday, October 1, 2011
Ignoring Case in SQLite Android Queries
Instead of using the "=?" string to match strings exactly, use "like?":
db.query(TABLE_NAME, COLUMNS, REG_COLUMN + " LIKE? ", new String[] {searchQuery}, null, null, null);
instead of:
db.query(TABLE_NAME, COLUMNS, REG_COLUMN + "=? ", new String[] {searchQuery}, null, null, null);
db.query(TABLE_NAME, COLUMNS, REG_COLUMN + " LIKE? ", new String[] {searchQuery}, null, null, null);
instead of:
db.query(TABLE_NAME, COLUMNS, REG_COLUMN + "=? ", new String[] {searchQuery}, null, null, null);
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")]
[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...
List
((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...
Saturday, August 27, 2011
Copying files in Java
This is something I've never really done much of, but when I've seen snippets of code which do this I've always thought how ugly and cumbersome it looks:
File srcFile = new File(sourceFilePath);
File destFile = new File(destinationFilePath);
FileInputStream in = new FileInputStream(srcFile);
FileOutputStream out = new FileOutputStream(destFile);
byte[] buf = new byte[2048];
int len;
while ((len = in.read(buf)) > 0)
{
try
{
out.write(buf, 0, len);
}
catch (Exception e)
{
}
}
out.flush();
in.close();
out.close();
etc...
But there is now, at last, an easier way:
import java.nio.channels.FileChannel;
...
File srcFile = new File(sourceFilePath);
File destFile = new File(destinationFilePath);
FileInputStream in = new FileInputStream(srcFile);
FileOutputStream out = new FileOutputStream(destFile);
FileChannel srcFileChannel = in.getChannel();
FileChannel destFileChannel = out.getChannel();
destFileChannel.transferFrom(srcFileChannel, 0, srcFileChannel.size());
srcFileChannel.close();
destFileChannel.close();
...
Subscribe to:
Posts (Atom)