Is there a way I can get application name, application version and application icon, for the package that is not yet installed? (for some apk file on sdcard
// Install a known apk file from the SD-Card
// or launch it if installed.
// -hsigmond
protected void runAppFromApkFileOnSdCard() {
final PackageManager pm = getActivity().getPackageManager();
String apkFileName = "application_name.apk";
String fullPath = "/sdcard/"+apkFileName;
PackageInfo packageInfo = pm.getPackageArchiveInfo(fullPath, 0);
Intent intent = pm.getLaunchIntentForPackage(packageInfo.packageName);
if( intent == null ){
File file = new File(fullPath);
intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(Uri.fromFile(file),
"application/vnd.android.package-archive");
}
startActivity(intent);
}
Use:
packageInfo.applicationInfo.['name','icon','logo'] etc.
Example Icon:
Drawable icon = packageInfo.applicationInfo.loadIcon(getActivity().getPackageManager());