I’m also trying to figure out. I’m getting the same error as yours, “Error: File Not Found”.
Where’s the root directory for the url so the file can be opened? Any workaround?
Well guys if anyone still curious … I already solved this problem by not taking on the getting the file from assets because this is kinda impossible thing working with hybrid … if we were working native this would be possible.
so to make this happen I made the file I needed downloadable from my web server www.mywebiste.com/file.apk and used this code to download it and install it on the android device :
import { Component } from '@angular/core';
import { Platform, LoadingController } from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';
import { FileOpener } from 'ionic-native';
import { File } from 'ionic-native';
import { Transfer } from 'ionic-native';
import { HomePage } from '../pages/home/home';
declare var cordova: any;
@Component({
template: `<ion-nav [root]="rootPage"></ion-nav>`
})
export class MyApp {
rootPage = HomePage;
constructor(platform: Platform, public loadingCtrl: LoadingController) {
let me = this;
platform.ready().then(() => {
let loading = me.loadingCtrl.create({
content: 'Preparing Download ...'
});
loading.present();
File.createDir(cordova.file.externalDataDirectory, "app", true).then(function(link){
const fileTransfer = new Transfer();
let url = 'http://myserver.com/app.apk';
fileTransfer.download(url, cordova.file.externalDataDirectory +"app/app.apk").then((entry) => {
loading.dismiss();
FileOpener.open(entry.toURL(), "application/vnd.android.package-archive").then(
function(){
console.log("success");
},function(err){
console.log("status : "+err.status);
console.log("error : "+err.message);
});
}, (error) => {
console.log(error);
});
},function(error){
console.log(error);
});
StatusBar.styleDefault();
Splashscreen.hide();
});
}
}
i am using same code some devices work well but with some devices i get error:
Activity not found: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://com.ionicframework.power10fs142463.opener.provider/external_files/Android/data/com.ionicframework.power10fs142463/files/newVersions/Power10_FS_0.4.apk typ=application/vnd.android.package-archive flg=0x40000000 }"