儘可能簡潔:嘗試從安卓應用程序toprogrammatically安裝APK時解析錯誤
-APK文件未損壞。
- 我可以瀏覽到手機文件系統中的APK,並從那裏手動安裝它,沒有問題。
-I使用以下代碼啓動安裝過程。文件的位置是正確的證實:
public void installfromlocal()
{
String downloadfilelocation = getsharedresourcestring("updatepackagelocation");
Log.e("installing from",downloadfilelocation);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(downloadfilelocation)), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
到目前爲止,我可以從互聯網上幾個小時收集的,顯然我不能讓我的應用程序從外部存儲程序安裝APK。我也可以顯然不復制文件到內部存儲並從那裏安裝。
那麼現在呢?另外,我沒有收到來自Logcat的消息。我只有一個彈出窗口提醒我解析apk時出現錯誤。
** **確實**是'downloadfilelocation'指向? – CommonsWare
'downloadfilelocation'您在日誌中獲取的路徑是否正常? – Vikrant
是的,位置很好。它指向file:///storage/sdcard0/Download/org.mycompany.myapp.apk –