App Settings and Child Classes

I am in the process of refactoring some of my data fields to use a parent class for common code and child class inheriting from the parent to add additional functionality.  All is going well but I cannot get the App Settings to work either in the Simulator or when side loading onto a device.

So I have the Base classes implement core functionality.  The child classes extend from the base calling any base methods as necessary.

The App Settings dialogue seem to run as normal on Windows.  But no changes made to the settings are fed through to the simulator.

Copying the updated settings file to the device has no effect either.

The code picks up the default values from the resource file but I can't get it to accept any updates.

Anyone else experienced issues around App Settings and 

  • OnSettingsChanged is actually called after the new settings have been merged in your running app.

    Not sure why you're extending AppBase for this.

    class MySettings {
      var a=0;
      
      function initialize() {
        load();
      }
      
      function load() {
        a=Application.Properties.getValue("a");
      }
    }
    

    When the app starts,

    Settings=new MySettings();

    and in onSettingschanged()

    Settings.load()

    and to use a setting, reference

    Settings.a

  • I am using the following code within the child compute methods

    var app = Application.getApp();
    
    for (var i = 0; i <= 5; i++){
        userFields[i] = app.getProperty("userField" + i) == null ? 0 : app.getProperty("userField" + i); 
    }

    Which works fine until it resides in the child class compute().  All I get back is the default values from the resource file.  I don't want this in the base class as it is functionality which is not needed for all children.

  • compute as in a DF compute()?  Here is no reason this needs to be done ever second.  

    And you don't need to use a child class.  Even with the way you're doing it, the class is always in memory.

    If you want to do some code reductions, have you looked at jungles or for code sharing with. barrels?

  • Whether it is in the compute() or initialize() I still can't get the settings updated.  I moved to compute to see if that would help, it was in the child initialize() a few hours ago.

    Jungles only let me differentiate on device type I think.  I want different data fields/binaries for the same device.

    I have not put in barrels as I wanted the flexibility to hook into and override base class methods. But if I can't get this to work I will have to investigate this.

  • If you want different prgs for the same device, you need separate projects, each with their own manifest ID, and then you can use different jungles for each project

  • I have different projects with different manifests.  I am using eclipse linked files to share the same base class into each project.  This gets me the differentiation I need while sharing common code.  It is just that device settings isn't working.

  • Put in println calls starting with one in onSettingsChanged in AppBase to make sure you're getting that far.

  • Well I have single stepped it through the eclipse debugger and the values returned from app.getProperty never vary from the default values set in the resource file.

    Tried stripping out the settings vars to globals and calling the update through onSettingschanged().

    Updating the properties through the eclipse App Settings Editor triggers onSettingschanged() but again the return values from app.getProperty match the defaults from the resource file and not those set in App Settings Editor 

  • Try file>Delete All Apps in the sim to make sure you don't have conflicting manifest IDs

  • That did it!  I had already refreshed the manifest ID on the app, as I thought it might be something like that, but that seemed to have no effect, however the Delete All Apps brought it back to life.

    Much appreciated for your guidance.