B4A Library [Library] Advanced Notification

Hello again Guys and girls (Yes there are some!)

Here is another Notification Library.

To clear up an confusion between this and my Custom Notification Library I will explain the difference between the 2 now.

IF you require the ability to create your own xml layouts for notifications use the Custom Notification Library. If you wish to use the standard layout but have the other extra options available then us this one. Hope I don't confuse people too much.

Because this library uses the standard Notification object it DOES NOT suffer the same 4.0.3 bug mentioned in the Custom Notification post.

Documentation:

  • AdvancedNotification
    Properties:
    • AlertOnce As Boolean
      Sets whether the notification sound and/or vibration should sound each time the notification is sent, even if it has not been cancelled before.

    • AutoCancel As Boolean
      Sets whether the notification will be cancelled automatically when the user clicks on it.

    • Icon As Boolean
      Sets the icon to be displayed.
      The image file should manually copied to the Objects\res\drawable\ folder and set to read-only.
      The file name is case sensitive and should not contain the file extension.
      You can use "icon" to use the applications icon.

      Example:
      'NotificationIcon.png copied to Objects\res\drawable\ folder and set to read-only.
      an.Icon = "NotificationIcon"

    • Insistent As Boolean
      Sets whether the sound will play repeatedly until the user opens the notifications screen.

    • Light As Boolean
      Sets whether the notification will show a light.

      Example:
      an.Light = False

    • NoClear As
      Sets whether the notification should NOT be cancelled when the user clicks the Clear All button.

      Example:
      an.NoClear = True 'Notification will not clear.

    • Number As Int
      Gets or Sets the number that will be shown on the icon.
      This is useful to represent multiple events in a single notification.

    • OnGoingEvent As Boolean
      Sets whether the notification is an 'ongoing event'.
      The notification will be shown in the ongoing section and will not be cleared.

    • Sound As Boolean
      Sets whether the notification will play a sound.

      Example:
      an.Sound = False

    • TickerText As String
      Sets the Ticker Text which shows along side the status bar icon on new notification.

      Example:
      an.TickerText = "New notification"

    • Vibrate As Boolean
      Sets whether the notification will vibrate the device

      Example:
      an.Vibrate = False

    Methods:
    • Cancel (Id As Int)
      Cancels the notification with the given Id

    • Initialize
      Initializes the notification. By default the notification plays a sound, shows a light and vibrates the phone.

      Example:
      Dim an as AdvancedNotification

      an.Initialize()
      ...

    • IsInitialized As Boolean

    • Notify (Id As Int)
      Displays the notification.
      Id - The notification Id. This Id can be used later to update the notification (by calling Notify again with the same Id),
      or to cancel the notification

    • SetCustomSound (path As String)
      Sets a custom sound to be played on new notification.

      NOTE:
      Automatically sets 'an.Sound = False'
      This is required for this method to work, Do not set 'an.Sound = True' after setting a custom sound or the custom sound will no work.

      Example:
      an.SetCustomSound("file:///sdcard/notification/ringer.mp3")

    • SetCustomVibrate (Values As Long())
      Sets A custom vibrate sequence for notification Vibration
      The Array of values can be as long as you wish.
      The First Value is the pause before vibration starts, then it's ON, OFF, ON, OFF, etc.

      NOTE:
      Automatically sets 'an.Vibrate = False'
      This required for this method to work. Do not set an.Vibrate = True' after setting a custom vibration pattern or the custom pattern will not work.

      Example:
      Dim v() as Long

      v = Array as Long(0, 100, 200, 300, 400)
      an.SetCustomVibrate(v)

    • SetInfo (Title As String, Body As String, Activity As Object)
      Sets the message text and action.
      Title - The message title.
      Body - The message body.
      Activity - The activity to start when the user presses on the notification.
      Pass an empty string to start the current activity (when calling from an activity module).
      Example:
      an.SetInfo("Some title", "Some text", Main)

    • SetInfo2 (Title As String, Body As String, Tag As String, Activity As Object)
      Similar to SetInfo. Also sets a string that can be later extracted in Activity_Resume.
      Title - The message title.
      Body - The message body.
      Tag - An arbitrary string that can be later extract when the user clicks on the notification.
      Activity - The activity to start when the user presses on the notification.
      Pass an empty string to start the current activity (when calling from an activity module).
      Example of extracting the tag:
      Sub Activity_Resume
      Dim in As Intent
      in = Activity.GetStartingIntent
      If in.HasExtra("Notification_Tag") Then
      Log(in.GetExtra("Notification_Tag")) 'Will log the tag
      End If
      End Sub

Installation:

Extract the AdvancedNotification.zip
Copy 'AdvancedNotification.jar' & 'AdvancedNotification.xml' to your b4a library folder.
Then just add the library as usual and code away.

Update: V1.2
Due to rushing the release of this library I missing a very important part out. The permission for the Vibrations. Again, this is thanks to NJDude for spotting it. Now added. If you have used this library on any projects please update and recompile your app. Thanks and sorry for any inconvenience caused.

Hope you find this useful!
Thanks

Barx
 

Attachments

  • AdvancedNotification.zip
    5.4 KB · Views: 1,306
Last edited:

Kevin

Well-Known Member
Licensed User
Longtime User
Sweet! Out of curiosity, has anything changed since the one you made for me in the other thread or is this essentially the exact same thing? Just wondering if I should update the library.

:sign0098:
 

Inman

Well-Known Member
Licensed User
Longtime User
One change for sure is the ability to set custom sounds instead of default one
 

barx

Well-Known Member
Licensed User
Longtime User
Nothing changed as far as the issuing code is concerned. Just finished / tidied up documentation and added missing feature(s).

Sent from my HTC Desire Z
 

Kevin

Well-Known Member
Licensed User
Longtime User
Barx:

Per your post in my bug thread, if it wouldn't be too much work to initially set the object defaults to no vibration and no sound, I would appreciate it if you could do that. I hate to ask any more favors of you but I really would like to get this fixed.

Assuming you do change that, it shouldn't affect someone WANTING to add vibration and sound, should it? It does seem like this could be the culprit though.

Also, this would be a change that you could control in your library or something that Erel would have to change in the core functionality? (Sorry, I'm completely dense in regard to how this all works. :D)
 

barx

Well-Known Member
Licensed User
Longtime User
Hey Kevin,

Anybody that knows me on here will tell you I don't mind helping out where I can. I have editted you a special 'kevin' version where the required defaults are set to off. Well, At least I think they are, Not got time to test at mo so test on your own device first ;)

This is done in the initialize method. I'm not sure it will make any difference, but it wont hurt to try.

I can't remember if I've asked you this before, but is the 'other' app free. Would it be an option to reverse engineer it and see how he uses notification object. A little naughty granted.

How many reports of this have you had? I may be clutching at straws here, but could it be the competitor making false claims to try and 'put down' your app. Again, I may have already asked that, it's been a while since we have spoke on this subject. I thought it was dead and burried. lol

NOTE TO EVERYONE ELSE:
This is only a test version for Kevin, please don't download and use as there is no gain. Thanks
 

Attachments

  • AdvancedNotificationk.zip
    5.6 KB · Views: 404

Kevin

Well-Known Member
Licensed User
Longtime User
Wow! Thanks!

If it were only comments that mentioned it then I could suspect it is not a real problem, but I have seen comments and also have gotten emails. I also have a FAQ system on my site and it shows page views. While that isn't the most popular, it has had quite a few hits. I really wish I had a device I could test on and see it for myself but alas I don't.

I'm just about to leave work soon (12 hour night shift) but as soon as I get home I'll check out the library and give more details and thoughts.

Thanks again! :D
 

Kevin

Well-Known Member
Licensed User
Longtime User
Well, I installed the custom library and uncommented my test code I used a while back. It seems that it still works fine in the sense that I can enable vibrations and sounds and they still work on my phone, and of course with those disabled, I get no vibration or sound on my phone. So far so good.

So the big test will be whether or not this fixes the issue on the small handful of affected phones. I was working on a minor update last night (slow night at work!) and stumbled on a bigger issue that bothers me so I will probably release an update today. I don't have time to wait on the one guy who tested the notifications for me so I am going to just release it and see how people react in the comments. :D If it seems to be fixed, I'll add it to my release notes, otherwise nobody will have to know I even tried. ;)

On the issue itself.....

Yes, the other app is free and I suppose I could reverse engineer it. However, I assume he just initializes the object the way he wants it from the start (no vib, no sound). I think it is conceivable that for whatever reason, on some phones perhaps it just goes with the original initialization options? I have no idea. I don't even know how this works. Does your library control the B4A object (which in turn controls the true Android object) or does your library control the true Android object directly?

That probably doesn't even make any sense, and if not, that would be because I don't know what the hell I'm talking about. :D

Hopefully this will do the trick, and if so, I will most definitely update this thread either way. I think that if it does happen to fix it, then perhaps an update to B4A would be in order, but we'll see what happens first.

I appreciate your help with this, and especially for making custom versions of your library for me. My fingers are crossed.... I really hope this works but at this point I don't think I have anything to lose.
 

barx

Well-Known Member
Licensed User
Longtime User
Can you provide a list of devices you are seeing issues on, somebody may have one if there are more than just the droid charge (i think that was the original problem device). Let me know the other apps name if you don't mind.

I'm going to have to read the original post on this to re-cap as a few of the details are a little scetchy in my memory. lol
 

Kevin

Well-Known Member
Licensed User
Longtime User
The only ones that I have somewhat confirmed (?) that it happens on is the Droid Charge and LG Marquee.

The competing app can be found here.

I just posted my update to the market but it isn't pushed out yet. I will email the one guy who tried testing for me and ask him to let me know if it is any better after he gets a chance to install and try the latest version.
 

Kevin

Well-Known Member
Licensed User
Longtime User
No feedback yet, so I don't know if it is fixed or not. I emailed the guy who helped me before but as my luck (and his luck as well) would have it, he lost his Charge a few weeks ago so he is using a different phone now. :(

Sooner or later I'm sure I'll hear something.
 

barx

Well-Known Member
Licensed User
Longtime User
I just noticed that the droid charge is a sammy device. I thought all droids were motorola's. Have to tried the app on something like a sgsIII? Sometimes sammy bugs are cross device if you know what I mean. I can test on a sgsIII as the wife has one ;)

But I'm not paying, lol

Sent from my HTC Desire Z
 

Kevin

Well-Known Member
Licensed User
Longtime User
I don't know why I didn't think of this before, but I have just updated the FAQ on my site to request that those affected by this contact me through the app which sends device information. At least this way I can possibly find out what all devices this happens on and potentially find more beta testers.

As far as testing on your wife's phone, I should have mentioned that the free version of my app started showing notifications in the past couple versions, so you wouldn't need to buy it anyway. The current market version may or may not vibrate though since it uses your updated test version of the library. If you want to try it on your wife's phone send me a PM with your email address and I can send you the previous version and current version and you can test on your wife's phone though I don't know how far you'd get since the app requires satellite hardware that you would not have (specifically, DirecTV satellite receivers & DVRs).

Another thought though would be to simply make a small test app using your original version of the library (or the built-in B4A function) with a couple of buttons - one to show a notification and one to hide it - and see if it vibrates your wife's phone even with vibration disabled.
 

barx

Well-Known Member
Licensed User
Longtime User
Well, as for the latter (test app) I can tell you this. My one and only (so far) released app Note-ification uses the custom notification library and the app gives the user the option to turn on/off vibration. It works fine on all the devices I have tested on including the wifes. So I guess that rules that out.

And yes your right, I don't have that hardware ;)

Sent from my HTC Desire Z
 

wes58

Active Member
Licensed User
Longtime User
I have tried this library and everything work great, except for notification light and number.
Has anyone managed to get any of these show?
 

barx

Well-Known Member
Licensed User
Longtime User
For the number the code to use is:

B4X:
an.Number = 2

As for the Light, None of the notification libs or the standard b4a object seem to work on my device, but I assumed it was just mine as no-one else reported any problems, the library uses the same code as the standard b4a object. So, if one works, the other should.
 

barx

Well-Known Member
Licensed User
Longtime User
Just to clarify, I'm running a custom rom. And the developers of the rom had issues with getting the led to work correctly on this devce. This is why I assumed the light wasn't working for notifications on it.

Sent from my HTC Desire Z
 

wes58

Active Member
Licensed User
Longtime User
For the number the code to use is:

B4X:
an.Number = 2

As for the Light, None of the notification libs or the standard b4a object seem to work on my device, but I assumed it was just mine as no-one else reported any problems, the library uses the same code as the standard b4a object. So, if one works, the other should.

That's the same way I tried to use the Number, but it doesn't work.
The light doesn't work with standard b4a object either.
I have Galaxy SIII. So I guess it is the phone.
 

barx

Well-Known Member
Licensed User
Longtime User
OK, I will try it out on the wife new sIII when I get a few minutes. Notifications have changed a bit since the original b4a object was created, maybe it's time for an update....
 

Inman

Well-Known Member
Licensed User
Longtime User
That's the same way I tried to use the Number, but it doesn't work.
The light doesn't work with standard b4a object either.
I have Galaxy SIII. So I guess it is the phone.

I have noticed that the notification number doesn't show up on Android 4.0 devices, while it works on Android 2.3 devices. So may be it is OS dependent.
 
Top