public static void doInstallApk(Context context, String apkName) {
// Copy the given asset out into a file so that it can be installed.
// Returns the path to the file.
byte[] buffer = new byte[8192];
InputStream is = null;
FileOutputStream fout = null;
try {
is = context.getAssets().open(apkName);
fout = context.openFileOutput("tmp.apk", Context.MODE_WORLD_READABLE);
int n;
while ((n=is.read(buffer)) >= 0) {
fout.write(buffer, 0, n);
}
} catch (IOException e) {
Log.i("InstallApk", "Failed transferring", e);
} finally {
try {
if (is != null) {
is.close();
}
} catch (IOException e) {
}
try {
if (fout != null) {
fout.close();
}
} catch (IOException e) {
}
}
File APKFileStreamPath= context.getFileStreamPath("tmp.apk");
Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
intent.setData(Uri.fromFile(APKFileStreamPath));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
// intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
// intent.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME,
// ContextWrapper.getApplicationInfo().packageName);
context.startActivity(intent);
}
주석처리해논 부분에서 에러납니다...
그리고 루팅이용해서 까는건 감도 안잡히네여... 도와주세요




어떤 에러가 나는지 알려주셔야 할듯??
저는 관련 퍼미션은 매니페스트에 다 선언해놓고
다운 받은 APK 파일을 아래와 같이 실행 시킵니다.
File apkFile = new File(Environment.getExternalStorageDirectory()+ FileName);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType( Uri.fromFile(apkFile), "application/vnd.android.package-archive");
context.startActivity(intent);