BestPractice2Go
BestPractice2Go

Reputation: 305

Manage update from an apk programmatically

I try to update an App on Google Glass programmatically but ended everytime in following error message:

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" />

My 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"/>

and my method to call the 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)

but when I use this lines:

val intent = Intent(Intent.ACTION_INSTALL_PACKAGE)
intent.setDataAndType(Uri.fromFile(outputFile),
            "application/vnd.android.package-archive")
startActivity(intent)

I got following error on start:

"There was a problem parsing the package".

.apk is in internal storage in Pictures/apks/, doesn't have a external storage on google glass. What I am doing wrong?

Upvotes: 0

Views: 418

Answers (0)

Related Questions