Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-3949

Add code fix to broken activity sequence

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • 2.7.0, 2.8.0
    • None
    • cordova-android
    • None

    Description

      If installing an app via sideloading on Android and opening it immediately after install via package installer, going through several pages, then pressing Home and later resuming the app later via opening the app from the may break the page sequence by creating a new CordovaActivity instance on top of the previous one.

      Tested on a Galaxy Nexus, Android 4.2

      Steps to replicate:

      1. Copy attached APK over to phone storage and install it.
      2. Click 'Open' when the package installer has installed the app, instead of clicking 'Done'
      3. Press the button in index.html to open the next page.
      4. Press Home to pause the app, then reopen the app from the app drawer (not the Recent Apps list).
      5. The app will relaunch as if it were a new activity instance (showing splashscreen again if configured, and adds index.html to the page sequence, instead of returning to where the user last was)
      6. Pressing back at this index page closes the new CordovaActivity and returns to the second page from the previous activity.

      These steps can't be replicated if the app was originally opened in the app drawer, a shortcut in the homescreen, or launched via Eclipse's Run button. Some bugs filed on Android's issue tracker suggest this can happen by clicking 'Open' on apps freshly installed from the Play Store too.

      This probably is an Android issue with the package installer (probably due to the package installer calling a non-standard intent) and not PhoneGap, but appears to be fixed by using singleTop as the activity launch mode, or adding code before calling super.loadUrl() in the activity to check for Intent anomalies:

              Intent intent = getIntent();
              String intentAction = intent.getAction();
              if (!isTaskRoot() && intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null) {
              	if(intentAction.equals(Intent.ACTION_MAIN)) {
      	            Log.d("Cordova", "This isn't the root activity. Clearing it and returning to the root activity.");
      	            finish();
      	            return;
              	}
              }
      

      Attachments

        1. Cordova281-debug.apk
          386 kB
          Kuan Yi Ming

        Activity

          People

            bowserj Joey Robert Bowser
            yiming.kuan Kuan Yi Ming
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: