protectedvoid runAppFromApkFileOnSdCard(){
       
finalPackageManager 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   =newFile(fullPath);
            intent      
=newIntent();
            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.
 
 
 
FROM:http://stackoverflow.com/questions/5661418/get-apk-file-icon-version-name

Example Icon:

Drawable icon = packageInfo.applicationInfo.loadIcon(getActivity().getPackageManager());
arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()