lead bolt notification running in Serivce Module

walterf25

Expert
Licensed User
Longtime User
Hello everyone, i'm working on a live wallpaper app, i would like to add leadbolt notifications on the app, i need some help figuring this out, when i declare the variable on the sub Process globals i get an error saying that the leadbolt variable can not be declared there, i then move it to a sub and use like this
B4X:
Sub notify2
Dim notify1 As LeadboltWrapper
notify1.Initialize("notify1")
notify1.AsynchTask = True
notify1.setListener
notify1.loadLeadboltAds("499693552", notify1.ADS_NOTIFICATION)
Log("sub notify2 called")
End Sub

but when the sub gets called i get this error,
LogCat connected to: TA28705IOE
--------- beginning of /dev/log/main

** Activity (main) Create, isFirst = true **
sub notify called
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
wallpaperservice_notifytimer_tick (B4A line: 127)
notify1.loadLeadboltAds("499693552", notify1.ADS_NOTIFICATION)

java.lang.IllegalStateException: View com.android.internal.policy.impl.PhoneWindow$DecorView@40540bb8 has already been added to the window manager.
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:125)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
at android.view.Window$LocalWindowManager.addView(Window.java:424)
at android.app.Dialog.show(Dialog.java:241)
at anywheresoftware.b4a.debug.Debug.wait(Debug.java:202)
at anywheresoftware.b4a.debug.Debug.reachBP(Debug.java:252)
at anywheresoftware.b4a.debug.Debug.ErrorCaught(Debug.java:141)
at com.dandre.dev.livewallpaper.wallpaperservice._notifytimer_tick(wallpaperservice.java:262)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:136)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:103)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)


at android.app.ActivityThread.main(ActivityThread.java:3806)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: java.lang.IllegalStateException: View com.android.internal.policy.impl.PhoneWindow$DecorView@40540bb8 has already been added to the window manager.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:165)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:103)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3806)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: View com.android.internal.policy.impl.PhoneWindow$DecorView@40540bb8 has already been added to the window manager.
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:125)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
at android.view.Window$LocalWindowManager.addView(Window.java:424)
at android.app.Dialog.show(Dialog.java:241)
at anywheresoftware.b4a.debug.Debug.wait(Debug.java:202)
at anywheresoftware.b4a.debug.Debug.reachBP(Debug.java:252)
at anywheresoftware.b4a.debug.Debug.ErrorCaught(Debug.java:141)
at com.dandre.dev.livewallpaper.wallpaperservice._notifytimer_tick(wallpaperservice.java:262)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:136)
... 10 more
can anybody please help me figure this out, i know it may probably be something simple, but my brain is half asleep right now :(, any help will be appreciated.

thanks,
Walter
 

pluton

Active Member
Licensed User
Longtime User
Declare it in Sub Globals not process globals

B4X:
Sub Globals
Dim notify1 As LeadboltWrapper
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("Main")
   
   notify1.Initialize("notify1")
   'notify1.setListener() 'this line you can comment
        notify1.AsynchTask = True
   
   notify1.loadLeadboltAds("YOUR_SECTION_ID", notify1.ADS_NOTIFICATION)  
   
End Sub
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Notification on service Module

Hi Pluton thanks for the reply, i actually want to have the leadbolt notifications to run in a servce Module, your example will work in the main activity, but i want to be able to call the notifications at let's say every 4 hours, for some reason it won't work when i put that code in a service module.
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Notification on service Module

Hi SSG, i downloaded your version and I still have the same issue, it's frustrating that i have not been able to figure this out, i honestly don't understand why i get that error.
basically i have a live wallpaper application, and i need to add the leadbolt notification ads to it, i want to be able to call a leadbolt notification ad at let's say every 4 hours interval, when i declare the leadbolt variable in the service module that's when i get the error on the first post, i can't seem to figure out why!

:BangHead::BangHead::BangHead:
 
Upvote 0

ssg

Well-Known Member
Licensed User
Longtime User
Sorry Walter that it did not help.

One last try, what happens if aynctask is not set as true? Just wondering since it relates to some UI stuff (not a very techie person)...

Good luck!
 
Upvote 0
Top