Issue
Im trying to figure out an easier (more automated way) to see all the version numbers of the apk's (both user installed and preinstalled) that are currently installed on an Android device.
currently I have been going about it like this:
a. The version is in the apk
b. The apk is typically in /system/app
c. The package name to apk name can be found in /data/system/packages.xml
d. The tricky part is that the application NAME is usually in a string resource in the apk file – like strings.xml (default name)
e. This can also be done from within the android SDK using the PackageManager family of API’s
This is extremely time consuming and Im doing this for many, many, many devices. Im just thinking that there has to be an easier way then how Im going about it.
Thanks for the help, as always, its very appreciated.
Solution
I did it, whoooo!!! ..... I am posting this code to anyone else that need to find the packagenames and version names of everything on the device.
import java.util.List;
import android.app.Activity;
import android.content.pm.PackageInfo;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.util.Log;
import android.widget.TextView;
public class main extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String bldr = new String();
List<PackageInfo> packs = getPackageManager().getInstalledPackages(0);
bldr = "Total packages --> " + packs.size() + "\n";
for(int i=0;i<packs.size();i++){
PackageInfo p = packs.get(i);
bldr = bldr + "<" + p.packageName + ">" + "\t" + "v" + p.versionName + "\n";
}
TextView tv = new TextView(this);
tv.setMaxLines(packs.size() + 2);
tv.setMovementMethod(new ScrollingMovementMethod());
tv.setText(bldr);
setContentView(tv);
Log.w("com.tmobile.pr.showAllPackages", bldr.toString());
}
}
Answered By - Nefariis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.