I'm trying to write an Android 2.2 app that will find installed apps that can be moved to the SD card. The permission to do this is encoded in the AndroidManifest.xml file as the root-level attribute "android:installLocation". PackageInfo seems to have an interface to everything but this attribute. I can open the installed apk and extract the AndroidManifest.xml file, but it seems to be in some binary encoding format, which some random internet people have written a decoder for, but that seems like an awful lot of work.
Is there an interface that I'm missing?
As it turns out, while there's no direct API call to get
installLocation
, neither do I have to parse the binary XML manually, as the providedXmlResourceParser
works on it.Uh, I guess there's a
switch
in there with onecase
that should probably just be anif
. Oh well. You get the point.Considering all other direct attributes of the manifest tag are available from PackageInfo, I think you're right to look for it there.
I know it's not in the doc, but did you try anyway? Something like
I know this is probably very naive considering the doc may even be generated automatically - and I wouldn't dare suggest it if I could try it myself (stuck on API 7 at the moment due to retarded OS not supported anymore in 8)
If it doesn't work, I'm afraid they just overlooked that - I can't imagine they would put it elsewhere all of a sudden. In that case, you'll probably be stuck parsing the manifests by yourself indeed.
In the older API's from 2007, there was public fields in the PackageInfo class that gave all information on the internalLocation and other relevant information. For security reasons I am guessing they got rid of those convenient fields.
You may access this attribute by next example:
http://developer.android.com/reference/android/content/pm/PackageInfo.html#installLocation
was introduced in API 21
But this field exists even in Android 2.3 http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3_r1/android/content/pm/PackageInfo.java/