Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 22    Views: 162

mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
03/27/15 06:12 PM (9 years ago)

[SOLVED] Need some help with Android Auto Refresh

Hi guys! Last week I needed help with iOS Auto Refreshing, I needed the app to refresh upon FIRST install and every launch after - @Kittsy came in with his cape and saved the day, along with @aussiedra! https://www.buzztouch.com/forum/thread.php?tid=4E66E09A8294231DE57B8FF Now I need help for Android, can't seem to figure it out. Same specifications needed as iOS, but so far everything I've tried has failed. Any Android experts willing to help solve this mystery? I'll buy a free beer at the next meetup for the guy or gal that helps solve this for me. Maybe some nachos too. David
 
bigPaul
Lost but trying
Profile
Posts: 103
Reg: Mar 08, 2013
Darwin
4,530
like
03/27/15 08:48 PM (9 years ago)
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
03/27/15 08:50 PM (9 years ago)
Hey Paul! Thanks for posting - that's a different solution for a similar problem. They want it to "Auto Refresh" rather than having a popup ask - which is great, and half the problem solved, but the real juice of this problem I have is having it refresh literally on the first app install launch, which buzztouch inherently will not do. :-) David.
 
fusionsch
I hate code!
Profile
Posts: 516
Reg: Dec 28, 2010
Montreux Switze...
11,610
like
03/28/15 01:56 AM (9 years ago)
Hi guys, How funny... The title of this thread is ideal for my issue too... which is exactly the opposite! Still no clue: https://www.buzztouch.com/forum/thread.php?tid=3A3CED04F4149B0126B37A6 Sorry to interfere here, hope it won't upset anybody... If you have any tip, please post in the above-mentioned thread, not here! ;-) Cheers Jack
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
03/28/15 05:55 AM (9 years ago)
@mrDavid, You wanting it to refresh only after install and a pop up? The reason I ask this because you can code it in the lifecycle to refresh, for example in the onResume or OnPause method. Also, the swipe down feature can do a refresh also and an user can use the swipe down to refresh only. LA
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
03/28/15 06:23 AM (9 years ago)
Find the code snippet in activity_host: confirmRefreshAlert.show(); and replace it with: refreshAppData(); you should be able here to put here onload Save and clean/rebuild This will load without the alerts but if u want the alerts then make the code adjustmentI have tried it out You can change the default loading message, which says (Loading...) by default by going to /res/values/strings.xml. Open strings.xml in text mode and find the string name 'LoadingTitle', you can change that to whatever you like or disable it. LA
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/28/15 08:49 AM (9 years ago)
Cool idea and great solution!
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
03/28/15 09:40 AM (9 years ago)
Hi LA! These two conditions need to meet: 1. The app needs to refresh when the app launches for the first time after user installs. 2. The app needs to refresh every single time the app opens afterwards. Does your code accomplish this? Also, great to see you posting, I haven't been around much so I'm missing some faces lately but appreciate the help! David.
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
03/28/15 10:16 AM (9 years ago)
It's great to be back! Yes the code should accomplish both. LA
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
03/28/15 04:48 PM (9 years ago)
Hi LA, Okay, did extensive testing! 1. It DOES refresh every time you close and reopen the app, even if you force stop the app, so perfect. 2. On the FIRST launch, after installing the app, it does NOT refresh. Thanks for looking into this LA, really appreciate it :-) David.
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
03/28/15 08:42 PM (9 years ago)
Watch out for LA's smoke, he's burning some serious rubber down Route BT! Go LA, go! :-) -- Niraj
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
03/29/15 05:23 AM (9 years ago)
lol @Niraj! Hmm on the App not refreshing on first launch! It should do that anyways..lol LA
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
03/29/15 05:34 AM (9 years ago)
Try it during the lifecycle: onStart. That has to do it! LA
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
03/29/15 06:42 PM (9 years ago)
Solved! Thanks LA! David
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
03/29/15 07:39 PM (9 years ago)
Mighty awesome, LA is our teacher! Time to give our teacher an apple :-) -- Niraj
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
03/29/15 07:40 PM (9 years ago)
Here here! Niraj, are you still rocking around San Diego my friend? David.
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
03/30/15 05:49 AM (9 years ago)
@Niraj, It's a good feeling to come back to developing and still can remember things..lol LA
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
04/02/15 04:30 PM (9 years ago)
@LA, Party is cancelled. Damnit. I must have not tested well enough, because I found a pretty big issue. Currently, with the solution provided: http://pastebin.com/4Z7VKFi0 1. The app DOES refresh on first launch after install. 2. The app DOES refresh when closed or quit and then re-opened. The problem? The refresh code is run TWICE (at the same time) when going through condition #2 above. When you open the app like normal, it detects an update, and refreshes, but then the refresh code gets run AGAIN because of the onStart cycle, so it tries to refresh twice at the same time, and ends up crashing. LA, I hope I explained this well, could you let me know what you think? Thanks for your time, apologies. I owe you big. David.
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
04/02/15 04:41 PM (9 years ago)
Okay, I think I just had my light bulb turn on in my head. If the onStart refresh code starts at first launch and also during close/open the app, then why do we even need the refresh code in the popup? Let's just delete the entire code in confirmRefreshAppData and let it be, it's useless. Then we don't have it trying to refresh twice at the same time. I think this would work. Testing now. David.
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
04/02/15 07:34 PM (9 years ago)
Sweet -- nice epiphany! Report back with the final solution please.
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
04/02/15 07:40 PM (9 years ago)
That *was* the final solution ;-)
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
04/03/15 05:05 AM (9 years ago)
Yeah you wouldn't need it twice. I'm happy you found the solution. Sorry I couldn't get back to you in time. LA
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
04/03/15 11:02 AM (9 years ago)
I'll never forgive you LA :-)
 

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.