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

Splash screens not found on Android when application package name differs from class package name

VotersWatch issueWatchersLinkUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      Application splash screens are not found on Android when using a package id that differs from the class package structure. The diagnosis as reported elsewhere (http://stackoverflow.com/a/27378129/600339) is that the splash screens are resolved from CordovaActivity using getClass().getPackage().getName() rather than getPackageName().

      With CB-3679 this code has been moved into the SplashScreen plugin.

      — CordovaLib/src/org/apache/cordova/CordovaActivity.java
      +++ CordovaLib/src/org/apache/cordova/CordovaActivity.java
      @@ -23,9 +23,6 @@ import java.util.HashMap;
      import java.util.concurrent.ExecutorService;
      import java.util.concurrent.Executors;

      -import org.apache.cordova.CordovaInterface;
      -import org.apache.cordova.CordovaPlugin;
      -import org.apache.cordova.LOG;
      import org.json.JSONException;
      import org.json.JSONObject;

      @@ -362,7 +359,9 @@ public class CordovaActivity extends Activity implements CordovaInterface {
      String splash = preferences.getString("SplashScreen", null);
      if(this.splashscreenTime > 0 && splash != null)
      {

      • this.splashscreen = getResources().getIdentifier(splash, "drawable", getClass().getPackage().getName());;
        + // Use configured package name rather than class package name
        + // http://stackoverflow.com/a/27378129/600339
        + this.splashscreen = getResources().getIdentifier(splash, "drawable", getPackageName());
        if(this.splashscreen != 0)
        {
        this.showSplashScreen(this.splashscreenTime);
        @@ -1021,7 +1020,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
        if (this.splashDialog == null || !this.splashDialog.isShowing())
        Unknown macro: { String splashResource = preferences.getString("SplashScreen", null); if (splashResource != null) { - splashscreen = getResources().getIdentifier(splashResource, "drawable", getClass().getPackage().getName()); + splashscreen = getResources().getIdentifier(splashResource, "drawable", getPackageName()); } this.showSplashScreen(this.splashscreenTime); }

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            bsd Brian de Alwis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment