2014年6月30日 星期一

copy Assets to sdcard & install apk

 private void copyAssets() {
        AssetManager assetManager = getAssets();
        String[] files = null;
        try {
            files = assetManager.list("");
        } catch (IOException e) {
            //Log.e("tag", "Failed to get asset file list.", e);
        }
        for(String filename : files) {
            InputStream in = null;
            OutputStream out = null;
            try {
              in = assetManager.open(filename);
              File outFile = new File(Environment.getExternalStorageDirectory(), filename);
              out = new FileOutputStream(outFile);
              copyFile(in, out);
              in.close();
              in = null;
              out.flush();
              out.close();
              out = null;
            } catch(IOException e) {
                //Log.e("tag", "Failed to copy asset file: " + filename, e);
            }    
        }
    }
    private void copyFile(InputStream in, OutputStream out) throws IOException {
        byte[] buffer = new byte[1024];
        int read;
        while((read = in.read(buffer)) != -1){
          out.write(buffer, 0, read);
        }
    }

------------------------------------------------------------
//Install APK
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "app.apk")), "application/vnd.android.package-archive");
startActivity(intent);  

[Fixed]avast2014開機服務關閉,無法打開(cause ofMactype)


如果装了Mactype,原因是avast与mactype冲突。在你的mactype当前使用的配置文件的[UnloadDLL]中添加三行:
afwerv.exe
avastsve.exe 

Avast.setup
(AvastUI.exe可以不用排除,若排除前三个依旧无效,推荐再排除了这个试试)
排除后再重启下系统(切记)。
Related Posts Plugin for WordPress, Blogger...