dpa99c / cordova-diagnostic-plugin

Cordova/Phonegap plugin to manage device settings
539 stars 361 forks source link

Cold restart() does not relaunch app - Android 10 #428

Closed ScottWaring closed 3 years ago

ScottWaring commented 3 years ago

Bug report

CHECKLIST

Current behavior:

Cold restart closes the app but does not reopen the app in Android 10, leaving the viewer on the home screen. Testing on Android 9 and lower cold restart behaves as desired. Warm restart behaves as desired on Android 10.

Expected behavior:

Cold restart is desired to close then reopen app.

Steps to reproduce:

Programatically hit this function cordova.plugins.diagnostic.restart(onError, true);

Environment information


   Ionic CLI                     : 6.11.0
   Ionic Framework               : @ionic/angular 5.3.4
   @angular-devkit/build-angular : 0.801.3
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.3.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.0, (and 29 other plugins)

Utility:

   cordova-res (update available: 0.15.2) : 0.8.1
   native-run (update available: 1.3.0)   : 0.3.0

System:

   Android SDK Tools : 26.1.1 
   ios-deploy        : 1.10.0
   ios-sim           : 8.0.2
   NodeJS            : v10.15.1
   npm               : 6.8.0
   OS                : macOS Catalina

Runtime issue

Android build issue:

Console output

No Output

**** UPDATE Updating this block in doColdRestart resolves the issue for me, works on 7 - 10 (the versions available for me to test on)

protected void doColdRestart() {
        String baseError = “Unable to cold restart application: “;
        try {
           ...
                    if (mStartActivity != null) {
                        mStartActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                        c.getApplicationContext().startActivity(mStartActivity);  <--------- Replaced PendingIntent and AlarmManager
                        Log.i(TAG,“Killing application for cold restart”);
                        //kill the application
                        System.exit(0);
ScottWaring commented 3 years ago

https://github.com/dpa99c/cordova-diagnostic-plugin/pull/429 Created this PR

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.