我已经建立在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