I am currently using Open File package to open an apk file from local storage so I can install the said app using a button inside my flutter app and it doesn't work. I tried opening image from local storage it works just fine with this code :
OpenFile.open(_apkFilePath);
But it won't work if I do that exact code on apk file. Then I tried using picked file just like the example from Open File like the code below :
Future<void> onClickInstallApk() async {
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result != null) {
_apkFilePath = result.files.single.path!;
} else {}
final _result = await OpenFile.open(_apkFilePath);
print(_result.message);
setState(() {
_openResult = "type=${_result.type} message=${_result.message}";
});
}
I picked the apk file, and it works. The thing is I want apk file to be directly opened without using picked file. I thought that maybe my path was wrong, so I looked at the path gotten from picked file, turns out the file is cached on the app, with the path like this (/data/user/0/appId/cache/file_picker/AppName.apk). I am wondering is it because of the path? Or something else. Can anyone help me with this? When the apk file failed to open, the log doesn't show an开发者_如何学编程ything, as if it was a success opening the file, but on the device, the error was (There was a problem while parsing the package.).
精彩评论