[英]Android - Kotlin - Install APK file not working
I am trying to install a local APK file onto the device within my app, however it is not working.我正在尝试将本地APK文件安装到我的应用程序中的设备上,但是无法正常工作。 I've read other questions/posts on stackoverflow etc. and have done the following, but still can't figure out why it wouldn't work:
我已经阅读了关于stackoverflow等的其他问题/帖子,并进行了以下操作,但仍无法弄清为什么它不起作用:
$ adb push spotify.apk /sdcard/APKs/spotify.apk
$ adb push spotify.apk /sdcard/APKs/spotify.apk
下载了APK文件(spotify)并将其$ adb push spotify.apk /sdcard/APKs/spotify.apk
WRITE_EXTERNAL_STORAGE
, READ_EXTERNAL_STORAGE
and INSTALL_PACKAGES
declared in my AndroidManifest.xml
AndroidManifest.xml
声明了以下WRITE_EXTERNAL_STORAGE
, READ_EXTERNAL_STORAGE
和INSTALL_PACKAGES
I am using the following Kotlin code:我正在使用以下Kotlin代码:
if (Build.VERSION.SDK_INT >= 24) {
try {
val m = StrictMode::class.java.getMethod("disableDeathOnFileUriExposure")
m.invoke(null)
} catch (e: Exception) { e.printStackTrace() }
}
val intent = Intent(Intent.ACTION_VIEW)
val file = File(Environment.getExternalStorageDirectory().toString() + "/APKs/" + "spotify.apk")
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive")
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(intent)
But nothing happens, no log appears indicating any error and no app is installed - does anybody know what's going on here?但是什么也没发生,没有日志显示任何错误,也没有安装任何应用程序-有人知道这里发生了什么吗?
I am trying to install a local APK file onto the device within my app, however it is not working.我正在尝试将本地APK文件安装到我的应用程序中的设备上,但是无法正常工作。 I've read other questions/posts on stackoverflow etc. and have done the following, but still can't figure out why it wouldn't work:
我已经阅读了关于stackoverflow等的其他问题/帖子,并进行了以下操作,但仍无法弄清为什么它不起作用:
$ adb push spotify.apk /sdcard/APKs/spotify.apk
$ adb push spotify.apk /sdcard/APKs/spotify.apk
下载了APK文件(spotify)并将其$ adb push spotify.apk /sdcard/APKs/spotify.apk
WRITE_EXTERNAL_STORAGE
, READ_EXTERNAL_STORAGE
and INSTALL_PACKAGES
declared in my AndroidManifest.xml
AndroidManifest.xml
声明了以下WRITE_EXTERNAL_STORAGE
, READ_EXTERNAL_STORAGE
和INSTALL_PACKAGES
I am using the following Kotlin code:我正在使用以下Kotlin代码:
if (Build.VERSION.SDK_INT >= 24) {
try {
val m = StrictMode::class.java.getMethod("disableDeathOnFileUriExposure")
m.invoke(null)
} catch (e: Exception) { e.printStackTrace() }
}
val intent = Intent(Intent.ACTION_VIEW)
val file = File(Environment.getExternalStorageDirectory().toString() + "/APKs/" + "spotify.apk")
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive")
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(intent)
But nothing happens, no log appears indicating any error and no app is installed - does anybody know what's going on here?但是什么也没发生,没有日志显示任何错误,也没有安装任何应用程序-有人知道这里发生了什么吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.