B4A Library Notification Builder Library.

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hello,
have you ever implements a service that show a notification every day at a specific time? Can you help me?
 

barx

Well-Known Member
Licensed User
Longtime User
You issue the notification like any other. The trick is getting the service to start when you want.

Use StartServiceAt and set the Time to correspond to the right time on the right day. You can only schedule a service once at a time do once your service has started then you need to schedule the next start...
 

JDS

Active Member
Licensed User
Longtime User
Hi Barx,

I can't get it to work.

The error is:
Cannot get methods of class: barxdroid.NotificationBuilder.NotificationBuilder, disabling cache.
Error occurred on line: 92 (pushservice)
java.lang.RuntimeException: Method: setDefaultLight not found in: barxdroid.NotificationBuilder.NotificationBuilder

in Main
B4X:
Dim nb As NotificationBuilder

In Pushservice (service module)
B4X:
        Main.nb.Initialize
        Main.nb.DefaultLight = True 'fails at this line
        Main.nb.DefaultVibrate = True
        Main.nb.DefaultSound = True
        Main.nb.SmallIcon = "icon"

Any ideas?
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User

Hello,
I tried in a simple project and it's ok for me!
 

JDS

Active Member
Licensed User
Longtime User
I've created a new simple app.
Main:
B4X:
Sub Process_Globals
    Dim nb As NotificationBuilder
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
    StartService(test)
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

service module "Test":
B4X:
Sub Process_Globals
End Sub
Sub Service_Create
End Sub

Sub Service_Start (StartingIntent As Intent)
    Main.nb.Initialize
    Main.nb.DefaultLight = True
    Main.nb.DefaultVibrate = True
    Main.nb.DefaultSound = True
    Main.nb.SmallIcon = "icon"
End Sub

Sub Service_Destroy
End Sub

Same error...
 

barx

Well-Known Member
Licensed User
Longtime User
I don't think you can declare in process globals...
 

JDS

Active Member
Licensed User
Longtime User
But the line "Main.nb.initialize" can be executed without an error...

The "normal" Notification can be declared and used in a process globals. Whats the difference?
 

DonManfred

Expert
Licensed User
Longtime User
java.lang.RuntimeException: Method: setDefaultLight not found in: barxdroid.NotificationBuilder.NotificationBuilder
Error occurred on line: 92 (pushservice)
This error is telling about a servicemodule "PUSHSERVICE" but you say you are using the code you posted in post #306 in a "service module "Test""
Please upload your project (Export as ZIP) or check your module pushservice whether there is somewhere a "setDefaultLight" or not. It should be only "DefaultLight = true"
 

JDS

Active Member
Licensed User
Longtime User
Attached is the test file.
Thx in advance...
 

Attachments

  • NotificationFails.zip
    6.5 KB · Views: 230

JDS

Active Member
Licensed User
Longtime User
The attached ZIP is the same as my own. When I place
main.nb.notify(1) in the service_create then the app kills itself at that point.
 

DonManfred

Expert
Licensed User
Longtime User
The attached ZIP is the same as my own.
No, it isnt.
Thats the code from YOUR zip´s Sercive-Start
B4X:
Sub Service_Start (StartingIntent As Intent)
    Main.nb.Initialize
    Main.nb.DefaultLight = True
    Main.nb.DefaultVibrate = True
    Main.nb.DefaultSound = True
    Main.nb.SmallIcon = "icon"
End Sub
main.nb.notify(1) in the service_create then the app kills itself at that point.
My fault... It should have been service_start! Not create. Sorry.
 

lte5000

Member
Licensed User
Longtime User
Hi,

I have been using this library for quite a while... works great.

But I have one question/small problem...

When I set a large notification icon, the large icon will appear to be very poor quality/pixelated.

If I only set a small icon, it will look good (although it will be small, of course).

See attached screenshot for an example of what I'm talking about.
I also attached a small project that demonstrates the issue.

I think I'm probably just doing something wrong, but I'm about out of ideas.

Thanks for your help.
 

Attachments

  • test.png
    81.7 KB · Views: 276
  • test.zip
    43.7 KB · Views: 238

dieterp

Active Member
Licensed User
Longtime User
Hi Guys

I seem to be getting the same error as JDS:

Cannot get methods of class: barxdroid.NotificationBuilder.NotificationBuilder, disabling cache.

Was a solution found for this? I have copied all the relevant files into the Libraries folder, made sure that they are the latest update, upgraded to sdk 20. Not really sure what else to do?

Thanks in advance
 
Last edited:

daemon

Active Member
Licensed User
Longtime User
Me too getting same error:

Cannot get methods of class: barxdroid.NotificationBuilder.NotificationBuilder, disabling cache.

It doesn't come always though, generally comes on re-runs.
If I do Tools -> Clean Project and then run again, I haven't seen this error - but that is a pain.

@barx, have you seen it?
 

barx

Well-Known Member
Licensed User
Longtime User
All I can suggest is make sure all the code relating to the notification is in the same module. I.E don't declare it in Main and change settings / notify in another activity or service. If you wish to change the notification from another module repeat ALL the code and simply use the same ID

Hope this helps
 

daemon

Active Member
Licensed User
Longtime User
All the code is in same module. It is actually a background service.
I tried to create a simple test case, but I cannot reproduce it there
As I said, it has some kind of conflict with generated files or other resources. If I clean project and build, it goes through. Then, when I rebuild, some times I get this error.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…