[英]Android Things: How to install apk from device with pm install -r
我正在嘗試為Android Things app.apk
構建自動更新程序。 到目前為止,我已經將.apk
的新版本下載到/sdcard/download/app.apk
,也可以通過adb終端從那里安裝它,例如
adb shell
pm install -r /sdcard/Download/app
現在,我嘗試通過設備本身執行相同的操作。 目前我有這個
Process install = Runtime.getRuntime().exec("pm install -r /sdcard/Download/app");
install.waitFor();
但是什么也沒發生。 我也嘗試這樣打開外殼,但是這次我Cannot run program "su": error=13, Permission denied
Process install = Runtime.getRuntime().exec("su");
DataOutputStream out = new DataOutputStream(install.getOutputStream());
out.writeBytes("pm install -r /sdcard/Download/app");
out.flush();
是否可以從設備本身安裝下載的apk? 使用Intent.ACTION_VIEW
的常規方法也不起作用。 它空白了,就是這樣。 什么都沒發生。
使用ADB命令
adb install /path-of-your-apk/app.apk
您可以輕松啟動安裝提示:
Intent promptInstall = new Intent(Intent.ACTION_VIEW)
.setDataAndType(Uri.parse("file:///path/to/your.apk"),
"application/vnd.android.package-archive");
startActivity(promptInstall);
但是,未經用戶的明確許可,您無法安裝.apks
。 除非設備和您的程序已植根。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.