B4A Library Notification Builder Library.

barx

Well-Known Member
Licensed User
Longtime User
If you read the answer to this. This is how I understand it.

click


I tried to do this with my very first app 'Note-ification'. The results were good to start off, basically the idea is you use a transparent file for icon, and push it to the right (or left on some devices as I found). It works good on many devices, but others not so.
 

barx

Well-Known Member
Licensed User
Longtime User
setting the Priority to -2 may give the desired effect on 4.1+
 

lte5000

Member
Licensed User
Longtime User
Hi,

First, thanks for the great library BarX!

I have been using it in my app and it is working very well for the most part.

But I have one problem when using SetDeleteActivity.
When I use SetDeleteActivity, the delete activity that I assign runs as it should.
After the "delete" activity is finished, it runs Activity.Finish.
After this is when the problem occurs - my Main app activity comes up and I do not want this to happen.

The reason I need to use SetDeleteActivity is to clear my notification count when the user clears all notifications in the tray.

So my question is: Is there any way to keep the Main activity from showing after the "delete" activity runs Activity.Finish?


Thanks!
 

barx

Well-Known Member
Licensed User
Longtime User

Is it possible for you to upload a project showing the issue, I've tried recreating it on my device and once the delete activity shows, pressing back exits the app.
 

lte5000

Member
Licensed User
Longtime User
Attached is a project that should show the issue.

Whenever the deletenotification activity is called, the main activity will appear after the deletenotification activity is finished.

Thanks for looking into this.
 

Attachments

  • test.zip
    308.7 KB · Views: 347

barx

Well-Known Member
Licensed User
Longtime User
ok, tried your test project and on my s4 it all works as expected.

I start the app, get a notification. close the app.
Clear the notification and the delete activity shows in the logs closes and then nothing. Nothing else showing.

Maybe this is device specific
 

lte5000

Member
Licensed User
Longtime User
Thanks for testing it!

I am using a Google Nexus S 4G with Android 4.1.

I will try it on some more devices and see what happens.
 

barx

Well-Known Member
Licensed User
Longtime User
I have now tried this on 4 different handsets and all the same outcome.

handsets:
S4
S3
Galaxy Ace
HTC Desire Z / G2

going to be very hard for me to fix if I cannot re-create the issue
 

lte5000

Member
Licensed User
Longtime User
OK, not sure what to say...

I also tried my app on an emulator device and could not reproduce the problem there.

Even on my Nexus S it does not occur every time, maybe about 75% of the time.

I may avoid using SetDeleteActivity in my app for now... and just figure that the user actually has to open my app before the notification count gets cleared.

Again, thanks for your efforts.
 

barx

Well-Known Member
Licensed User
Longtime User
Maybe if I create another method that SetDeleteService and try making it so you can pass a service instead of an activity. Maybe a service will behave more reliably?
 

Malky

Active Member
Licensed User
Longtime User
Hi, I like this very much but have a problem with the icon after I drag the notification down? It is huge although I have a small icon in the drawable folder (as documented).

I tested it on a tablet as well and it is the same? I copied the same file into all drawable folders (icon.png) which is 32px x 32px.

Am I missing something?

Would also like to have small icons to delete or keep the notification. At the moment I just call an action to kill it in the service code.

B4X:
Sub KillNot
    nb.AutoCancel = True
End Sub

Any advice is more than welcome.

Cheers,

Malky
 

lte5000

Member
Licensed User
Longtime User


I will tell you what is working for me.
I am using a Small Icon and a Large Icon.

B4X:
nb.SmallIcon = "notify"
Dim res As Int = 48 * Density
Dim largenotify As Bitmap = LoadBitmapSample(File.DirAssets, "largenotify.png", res, res)
nb.LargeIcon = largenotify

In the res folder I have 5 subfolders, each containing a copy of notify.png:

drawable-xxhdpi - notify.png is 72px x 72px
drawable-xhdpi - notify.png is 48px x 48px
drawable-hdpi - notify.png is 36px x 36px
drawable-mdpi - notify.png is 24px x 24px
drawable-ldpi - notify.png is 18px x 18px

I then include one large icon file (largenotify.png - 144px x 144px) in the Files folder.
 

Malky

Active Member
Licensed User
Longtime User
Thank you for that information. I have scaled the images accordingly and will try this tonight when I get home from work. and will post my findings.

I will reply as soon as I can and will post my results.

Cheers,

Malky
 

Malky

Active Member
Licensed User
Longtime User

UPDATE: I have since renamed the files in all folders to icon.png. I get an icon with a notification. The initial icon is too big on the status bar. After the notification dies down and the ticker text disappears, the icon is perfect in the status bar and the correct size. When I pull the notification down, I go back to a huge icon again??

Malky
 

Malky

Active Member
Licensed User
Longtime User
Another update.
I have 'a' result.
When the Notification first comes in, I still get a block (part of a larger icon) in the status bar.
I copied the smaller icon.png to the assets dir and tried again after modifying Ite500's suggestion above.

B4X:
Dim res As Int = 48 * Density
    Dim smallnotify As Bitmap = LoadBitmapSample(File.DirAssets, "icon.png", res, res)
    nb.LargeIcon = smallnotify
    nb.SmallIcon = "icon"

This did the trick to display the notification thankfully.

I still don't understand why it doesn't use the available ones in the res folder. Or also why the Initial icon is way to large on receipt of notification?

Malky
 

lte5000

Member
Licensed User
Longtime User
Did you remember to set the icon files in the res sub folders to "read only"?
Otherwise it will not work.

Also, not sure if I understand you, but you can set nb.SmallIcon = "any_filename_you_choose_to_use".
For example, if you put an icon named homer.png in the res subfolders then set nb.SmallIcon = "homer".
 

Malky

Active Member
Licensed User
Longtime User
Yes, I did everything you said and scaled images to your instructions.

I ended up putting a suitable one in the files directory (which seems to be the only one that works)?

I have a message and am happy with that, BUT....... When I receive a message there is nothing in it if it contains a Euro sign (€)?????

If I remove it, the thing works fine? I would like to add an icon at the bottom again so the user can delete the Notification or not, but that comes out too large as well and i Just get a white rectangle? That is ok, I can handle that and use what I have.

At the moment the € sign is a bummer.

Malky
 

barx

Well-Known Member
Licensed User
Longtime User
If you do this, I will be very happy to give it a try!

I have hopefully added the required method to the lib. If you download and install the v2.31 file from the original post

I hope it works for you, let me know how you get on.

@Malky as for the image issue, hope you have it sorted, it is best to look at the guidelines given by google on this matter. This is nothing that can be sorted in the library, it literally just passes the images through to the underlying framework. If you had created the app in eclipse with jave, you would still suffer the same outcome. It's just a matter of having the right files in the right places.

Good luck to you both...
 

Malky

Active Member
Licensed User
Longtime User

Any idea on the Euro sign?

If I remove it I get the message ok and it appears in the debug panel as well.

If I include it, there is no response for the variable in the debug panel? (I still get the message, but only the header). The variable with the € is empty!

The rest I can handle

Cheers,

Malky
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…