1

I'm using cordova-plugin-file-transfer and plugin cordova-plugin-file-opener2
I can get the apk to download but I keep on running into this error ever time:

Error status: 9 - Error message: Activity not found: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://io.cordova.myappd06b01.opener.provider/external_files/Android/data/io.cordova.myappd06b01/files/someapp.apk typ=application/vnd.android.package-archive flg=0x40000000}

var targetPath = encodeURI(cordova.file.externalCacheDirectory + app_name);
var options = {};
var args = {
    name: app_name,
    url: event.url,
    targetPath: targetPath,
    options: options
};

downloadReceipt(args);

function downloadReceipt(args) {

var fileTransfer = new FileTransfer();
var uri = encodeURI(args.url);
          fileTransfer.download(
              uri, 
              args.targetPath, 
              function (entry) {
                    var pathToFile = cordova.file.externalCacheDirectory + args.name;
                    window.resolveLocalFileSystemURL(pathToFile, function (entry) {
                        cordova.plugins.fileOpener2.open(
                           entry.toURL(),
                             'application/vnd.android.package-archive', {
                                 error: function (e) {
                                     console.log('Error status: ' + e.status + ' - Error message: ' + e.message);
                                 },
                                 success: function () {
                                     console.log('file opened successfully');
                                 }
                             }
                        );
                    }, function (e) {
                        console.log('File Not Found');
                    });
                },
                function (error) {
                    console.log("download error source " + error.source);
                    console.log("download error target " + error.target);
                    console.log("upload error code" + error.code);
                },
                true,
                args.options
      );
}
var targetPath = encodeURI(cordova.file.externalCacheDirectory + app_name);
var options = {};
var args = {
    name: app_name,
    url: event.url,
    targetPath: targetPath,
    options: options
};

downloadReceipt(args);

function downloadReceipt(args) {

var fileTransfer = new FileTransfer();
var uri = encodeURI(args.url);
          fileTransfer.download(
              uri, 
              args.targetPath, 
              function (entry) {
                    var pathToFile = cordova.file.externalCacheDirectory + args.name;
                    window.resolveLocalFileSystemURL(pathToFile, function (entry) {
                        cordova.plugins.fileOpener2.open(
                           entry.toURL(),
                             'application/vnd.android.package-archive', {
                                 error: function (e) {
                                     console.log('Error status: ' + e.status + ' - Error message: ' + e.message);
                                 },
                                 success: function () {
                                     console.log('file opened successfully');
                                 }
                             }
                        );
                    }, function (e) {
                        console.log('File Not Found');
                    });
                },
                function (error) {
                    console.log("download error source " + error.source);
                    console.log("download error target " + error.target);
                    console.log("upload error code" + error.code);
                },
                true,
                args.options
      );
}
Dave2e
  • 22,192
  • 18
  • 42
  • 50
James Nicholson
  • 987
  • 10
  • 20

1 Answers1

0

I create the sample program and its working fine.

<script type="text/javascript">
    function clickMe(){
        alert("Function called");

        cordova.plugins.fileOpener2.open(
            '/sdcard/Download/android-debug.apk', 
            'application/vnd.android.package-archive'
        );
    }

</script>

<body>
    <button onclick="clickMe();">Click Me</button>

    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
    <script type="text/javascript">
        app.initialize();
    </script>
</body>

</html>

Its working fine for me. Its opened the application downloader.

Hiten
  • 724
  • 1
  • 8
  • 23