I want to show the current Hash/Branch Ref of the GIT repo in the About dialog of my Android Application. I can copy it by hand, but it's much more interesting to do it programmatically.
I have a library for my apps, so my activities and my applications inherit from my own library classes. So, I thought of adding a method [getGitHash()] to my library application class. I can refer to the current branch by reading .git/HEAD, which is virtually referenced in a res/raw file under Eclipse project (look here to see how it's done). My project has the R.raw.HEAD resource now.
But now the library can't reference the R.raw.HEAD, so I can't implement the method in the library. The method in the library should be something like this:
public static String getGitHash(int nDigits) { String hash = ""; SB_ResourceReader.LoadRAWFile(R.raw.HEAD,SB_Application.getContext()); return hash; } LoadRAWFile() is a static method to read raw file content and SB_Application.getContext() is another static method to retrieve... well, the app context.
Is it possible for the library to 'trust' that there will be a certain resource although it is not accessible when compiling?