我尝试以编程方式更新Google Glass上的应用程序,但每次都出现以下错误消息:
Failed to find configured root that contains /storage/emulated/0/Android/data/com.bp2go.glassapkupdater/files/Pictures/apks/app-release.apk
Manifest.xml
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
我的provider_paths.xml:
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="apks" path="Android/data/com.bp2go.glassapkupdater/Pictures/apks"/>
和我调用apk的方法:
var path_apk = getExternalFilesDir(Environment.DIRECTORY_PICTURES).toString()+"/apks/"
val fileName = "app-release.apk"
val path_to_apk = path_apk+fileName
val intent = Intent(Intent.ACTION_INSTALL_PACKAGE)
intent.setDataAndType(FileProvider.getUriForFile(this, "com.bp2go.glassapkupdater.fileprovider", File(path_to_apk)), "application/vnd.android.package-archive")
intent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
startActivity(intent)
但是当我使用以下行时:
val intent = Intent(Intent.ACTION_INSTALL_PACKAGE)
intent.setDataAndType(Uri.fromFile(outputFile),
"application/vnd.android.package-archive")
startActivity(intent)
启动时出现以下错误:
"There was a problem parsing the package".
.apk在Pictures / apks /中的内部存储中,在Google Glass上没有外部存储。我在做什么错了?