Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 1    Views: 44

TVanTasel
buzztouch Evangelist
Profile
Posts: 5
Reg: Feb 13, 2012
Willliamsburg, ...
10,550
04/19/16 03:18 PM (8 years ago)

Android - auto update - configuration data for new downloads & installs

Problem: Your app has been submitted to Google, you then make changes in the control panel. A user then downloads that app and the original BT_config data is used rather than getting the newest data from the server. What happened? On first install the app checks the server for the most recent ‘Published’ date. It then looks on the device for a cached ‘Publish’ date file in order to compare the dates. Since this is a new install, the cache files does not exist, so the app creates a cached file based on the most recent ‘Published’ date provided from the server. Due to this, the dates are the same, thus the user is not prompted to download the newest update from the server. ========================== The Fix (best option) ========================== Update the code so that if the cache file does not exist, we create a new cache file using the ‘lastPublished’ field from the originally published BT_config.txt file included within the app. Now the update process, upon first install, will compare the apps original ‘Published’ date with the servers ‘Published’ date. Below are the edits to make. File: BT_application.java // Add this line around line 60 in the ‘//properties…’ section private String lastPublished = ""; // Add this line around line 100 in the ‘//strings’ section lastPublished = ""; // Add this line around line 215 in the ‘//setting the string properties for this app’ section if(rootBT_item.has("lastPublished")) this.lastPublished = rootBT_item.getString("lastPublished"); // Added these lines around line 663 in the getters and setters section public String getLastPublished() { return this.lastPublished; } public void setLastPublished(String lastPublished) { this.lastPublished = lastPublished; } FILE: BT_activity_host.java // Around line 1307 in the ‘Handler reportToCloudHander’ section, change this: if(BT_fileManager.doesCachedFileExist(cachedConfigModifiedFileName)){ previousModified = BT_fileManager.readTextFileFromCache(cachedConfigModifiedFileName); BT_debugger.showIt(activityName + ":handleReportToCloudResults previousModified (value on device): " + previousModified); } // To this: if(BT_fileManager.doesCachedFileExist(cachedConfigModifiedFileName)){ previousModified = BT_fileManager.readTextFileFromCache(cachedConfigModifiedFileName); BT_debugger.showIt(activityName + ":handleReportToCloudResults previousModified (value on device): " + previousModified); }else{ //No cached file existed, so check lastPublished value in BT_config.txt previousModified = BT_strings.mergeBTVariablesInString(YOURAPP_appDelegate.rootApp.getLastPublished()); BT_debugger.showIt(activityName + ":handleReportToCloudResults lastPublished (value in BT_config.txt file on device): " + previousModified); } Note: in the text above, make sure you change the 'YOURAPP_appDelegate' to the actual name of your project file. ======================== Alternate Fix (simple) ======================== This alternate method only requires you to edit one file. It forces an ‘app updated’ when the cached file does not exist. So every new user will get an update on the first install/run of the app. FILE: BT_activity_host.java // Around line 1307 in the ‘Handler reportToCloudHander’ section, change this: if(BT_fileManager.doesCachedFileExist(cachedConfigModifiedFileName)){ previousModified = BT_fileManager.readTextFileFromCache(cachedConfigModifiedFileName); BT_debugger.showIt(activityName + ":handleReportToCloudResults previousModified (value on device): " + previousModified); } // To this: if(BT_fileManager.doesCachedFileExist(cachedConfigModifiedFileName)){ previousModified = BT_fileManager.readTextFileFromCache(cachedConfigModifiedFileName); BT_debugger.showIt(activityName + ":handleReportToCloudResults previousModified (value on device): " + previousModified); }else{ //No cached file, force update of App Data for all user. BT_debugger.showIt(activityName + ":handleReportToCloudResults No cached file, app needs refresh"); BT_debugger.showIt(activityName + ":handleReportToCloudResults No cached file, force app update”); confirmRefreshAppData(); } - Todd
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
04/19/16 08:39 PM (8 years ago)
Nicely done! :) Cheers! -- Smug
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.