首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

【转】在装置(sdcard)上获得apk文件的信息,安装或运行

2012-07-01 
【转】在设备(sdcard)上获得apk文件的信息,安装或运行http://stackoverflow.com/questions/5661418/get-apk-

【转】在设备(sdcard)上获得apk文件的信息,安装或运行
http://stackoverflow.com/questions/5661418/get-apk-file-icon-version-name


    protected void runAppFromApkFileOnSdCard()    {        final PackageManager pm = this.getPackageManager();        PackageInfo packageInfo = pm.getPackageArchiveInfo(fullPath, 0);        Toast.makeText(getApplicationContext(), packageInfo.packageName, Toast.LENGTH_LONG).show();//        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);    }

热点排行