我已經建立在Eclipse的應用程序,我已經放在這個應用程序的資源文件夾內的一些其他.apk
文件安裝apk文件放入資產文件夾內的文件。我已經增加了一些圖像按鈕的onClick我想安裝.apk
應用程序放在資產文件夾內,而不將其複製到SD卡外。我正在嘗試下面的代碼,但我得到了解析錯誤。下面是代碼:沒有將其拷貝到SD卡
ImageButton animal1 = (ImageButton)findViewById(R.id.imageButton1);
animal1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
AssetManager assetManager = getAssets();
InputStream in = null;
OutputStream out = null;
try {
in = assetManager.open("Animal Game.apk");
out = new FileOutputStream("/data/data/com.mypack.myproj/Animal Game.apk");
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
in.close();
in = null;
out.flush();
out.close();
out = null;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(newFile("/data/data/com.mypack.myproj/files/Animal Game.apk")), "application/vnd.android.package-archive");
startActivity(intent);
} catch(Exception e) {
Toast.makeText(getBaseContext(), "Error: "+e, Toast.LENGTH_LONG).show();
}
}
});
我得到的錯誤解析錯誤:
There was a problem parsing the package.
請人幫我解決這個錯誤
是的,它不能分析您的APK。那麼,你的APK有效嗎? – Raptor
雅我'APK'是有效的,並且它的'AIR application'我已經在我的設備上安裝了這個'APK' ..有什麼問題? – Sush19