Death to setProperties

One pet peeve of mine with Cordova was the fact that to do certain things, you still had to set certain properties such as splashscreen, timeouts and other minor details. These APIs traditionally only had documentation at the top of DroidGap.java, which is not a really intuitive place for documentation. Also, having to edit Java code just to do basic things means that we kind of failed at the whole HTML/Javascript based app thing, so we decided to move everything to config.xml and to get rid of this so that things are easier.

So, we replaced things like:

super.setIntegerProperty("splashscreen", R.drawable.splash);

with:


<preference name="splashscreen" value="splash" />

Now, we already did this change, but you may have noticed that setIntegerProperty and the other setProperty methods still work, but if you ever looked at your logcat, you should see this message:


Setting integer properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml

We’re not kidding. This is one of the things that will break when 3.0 comes out. If you haven’t moved your preferences to config.xml, do so now while you have the chance. We’re not going to do what we did with plugins and create a shim for this. We will have a full write-up about config.xml soon, but this is important, because if this change isn’t made, your application will break and we will close every bug related to this with “Won’t Fix”. Since config.xml is actually documented, we feel that this is a major improvement that’s been out in the wild for a while. setProperty was terrible, and should have been removed a while ago, and I’m really glad today that we’re able to move people over to this new way of setting Cordova properties.

Please keep reading the PhoneGap Blog for new updates about what is coming up for Cordova 3.0. We will have more posts landing there soon.

One thought on “Death to setProperties

  1. The path to config.xml is a wonderfull one, but I still see the need to change “super.loadUrl(Config.getStartUrl());” to “super.loadUrl(Config.getStartUrl(), timeout);” to make it happen. I took a peek at master’s Config.java, and there doesn’t seem to be code handling splashscreenTimeout or similar. Are there plans to make it happen?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>