pwlin / cordova-plugin-file-opener2

A File Opener Plugin for Cordova
MIT License
314 stars 587 forks source link

Android 8 open apk file cannot show installed successfully page. #260

Closed abcfy2 closed 5 years ago

abcfy2 commented 5 years ago

Expected Behaviour

After using file opener2 to open a apk file to upgrade self, should see apk installed successfully page.

Actual Behaviour

When I click install button, it crashed.

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Android 8.0+

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Any

Cordova CLI info

cordova info
cordova-lib@9.0.1 with:
  cordova-common@3.1.0
  cordova-create@2.0.0
  cordova-fetch@2.0.1
  cordova-serve@3.0.0

Environment:
  OS: win32
  Node: v10.16.0
  npm: 6.9.0

Plugins:
  cordova-plugin-advanced-http
  cordova-plugin-android-permissions
  cordova-plugin-app-version
  cordova-plugin-appavailability
  cordova-plugin-device
  cordova-plugin-file
  cordova-plugin-file-opener2
  cordova-plugin-file-transfer
  cordova-plugin-inappbrowser
  cordova-plugin-ionic-keyboard
  cordova-plugin-ionic-webview
  cordova-plugin-qrscanner
  cordova-plugin-screen-orientation
  cordova-plugin-splashscreen
  cordova-plugin-statusbar
  cordova-plugin-whitelist
  es6-promise-plugin

Plugin version

cordova plugin version | grep cordova-plugin-file-opener2

Here is the output:

cordova-plugin-file-opener2 2.2.0 "File Opener2"

Sample Code that illustrates the problem

    async installApp(apk){
        this.fileOpener.open(apk, 'application/vnd.android.package-archive').then(() => {
        }).catch(async e => {
            this.toast.show('Upgrade failed', 'middle');
        });
    }
abcfy2 commented 5 years ago

Related issue: https://github.com/pwlin/cordova-plugin-file-opener2/issues/245#issuecomment-497772945

abcfy2 commented 5 years ago

And I find add Intent.FLAG_ACTIVITY_NEW_TASK to FileOpen2.java could solve this issue.