powerino Active Member Licensed User Aug 12, 2018 #1 Hello, I have this problem with "BannerAd"... Error is here: Sub Activity_Resume timerInter.Enabled=True End Sub Somebody cna help me? thanks
Hello, I have this problem with "BannerAd"... Error is here: Sub Activity_Resume timerInter.Enabled=True End Sub Somebody cna help me? thanks
Erel B4X founder Staff member Licensed User Longtime User Aug 13, 2018 #21 And the answer is... You are waiting for PermissionResult in Activity_Create: Code: rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE) ' Wait For Activity_PermissionResult (Permission As String, Result As Boolean) Only later you are initializing the timer. The result is that Activity_Resume is called before the timer is initialized. Remember: From the code flow perspective Wait For is equivalent to Return. Why do you need the external storage permission? Why not save it in File.DirInternal or RuntimePermissions.GetSafeDirDefaultExternal? If you must request the permission then you need to handle the case where Activity_Resume is called before the permission is granted. Tip: it would have been easier to help you if you posted the logs. Upvote 0
And the answer is... You are waiting for PermissionResult in Activity_Create: Code: rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE) ' Wait For Activity_PermissionResult (Permission As String, Result As Boolean) Only later you are initializing the timer. The result is that Activity_Resume is called before the timer is initialized. Remember: From the code flow perspective Wait For is equivalent to Return. Why do you need the external storage permission? Why not save it in File.DirInternal or RuntimePermissions.GetSafeDirDefaultExternal? If you must request the permission then you need to handle the case where Activity_Resume is called before the permission is granted. Tip: it would have been easier to help you if you posted the logs.
DonManfred Expert Licensed User Longtime User Aug 13, 2018 #22 You are initializing Timer1 every time. You already get suggested to use it only when firsttime is true. It does not help if you just IGNORE the suggestion. Now Code: timer1.Initialize("timer1", 1000) Change it to Code: If FirstTime Then timer1.Initialize("timer1", 1000) End If Upvote 0
You are initializing Timer1 every time. You already get suggested to use it only when firsttime is true. It does not help if you just IGNORE the suggestion. Now Code: timer1.Initialize("timer1", 1000) Change it to Code: If FirstTime Then timer1.Initialize("timer1", 1000) End If
Erel B4X founder Staff member Licensed User Longtime User Aug 13, 2018 #23 Tip: Code: Sub CalculateMonth If monthTodayString = 1 Then monthString="Gennaio" else if monthTodayString = 2 Then monthString="Febbrai" else if monthTodayString = 3 Then monthString="Marzo" else if monthTodayString = 4 Then monthString="Aprile" else if monthTodayString = 5 Then monthString="Maggio" else if monthTodayString = 6 Then monthString="Giugno" else if monthTodayString = 7 Then monthString="Luglio" else if monthTodayString = 8 Then monthString="Agosto" else if monthTodayString = 9 Then monthString="Settembre" else if monthTodayString = 10 Then monthString="Ottobre" else if monthTodayString = 11 Then monthString="Novembre" else if monthTodayString = 12 Then monthString="Dicembre" End If End Sub Equivalent to: Code: Sub CalculateMonth Dim months() As String = Array As String("Gennaio", "Febbrai", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", _ "Settembre", "Ottobre", "Novembre", "Dicembre") monthString = months(monthTodayString - 1) End Sub You can of course make it a global variable. Upvote 0
Tip: Code: Sub CalculateMonth If monthTodayString = 1 Then monthString="Gennaio" else if monthTodayString = 2 Then monthString="Febbrai" else if monthTodayString = 3 Then monthString="Marzo" else if monthTodayString = 4 Then monthString="Aprile" else if monthTodayString = 5 Then monthString="Maggio" else if monthTodayString = 6 Then monthString="Giugno" else if monthTodayString = 7 Then monthString="Luglio" else if monthTodayString = 8 Then monthString="Agosto" else if monthTodayString = 9 Then monthString="Settembre" else if monthTodayString = 10 Then monthString="Ottobre" else if monthTodayString = 11 Then monthString="Novembre" else if monthTodayString = 12 Then monthString="Dicembre" End If End Sub Equivalent to: Code: Sub CalculateMonth Dim months() As String = Array As String("Gennaio", "Febbrai", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", _ "Settembre", "Ottobre", "Novembre", "Dicembre") monthString = months(monthTodayString - 1) End Sub You can of course make it a global variable.
powerino Active Member Licensed User Aug 13, 2018 #25 Ok Erel thanks. I need to re-open the interstitial on activity_resume, but the open is in loop... how to open ONLY when I close another Activity and re-open Main activity? Upvote 0
Ok Erel thanks. I need to re-open the interstitial on activity_resume, but the open is in loop... how to open ONLY when I close another Activity and re-open Main activity?
DonManfred Expert Licensed User Longtime User Aug 13, 2018 #26 You should always start a new thread for a new question Upvote 0