Android Question Service.StartForeground in Oreo

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
BarX has updated his notification builder library and notifications works perfect, here you go https://www.b4x.com/android/forum/threads/notification-builder-library.27376/page-26#post-554929.

I've been using it for 3 months now with absolutely no issues whatsoever...

Peter --
I really used a release from first page. Now I see new release. But when I tried to used it, I got error message inside Initialize. Did you check this release in Oreo 8.0.0 ? (8.0 does not have some methods, which are present in 8.1). In background (when your app is not started) ?
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Peter --
I really used a release from first page. Now I see new release. But when I tried to used it, I got error message inside Initialize. Did you check this release in Oreo 8.0.0 ? (8.0 does not have some methods, which are present in 8.1). In background (when your app is not started) ?

The I sent you you Initialize notifications as follows, it works perfext

B4X:
'Process Globals
    Private Notification As NotificationBuilder
    Private Channel As NotificationChannelBuilder 'New object
    Private ChannelID As String = "New_Mix_Notification" '"Channel_1"
    Private ChannelName As String = "New Mix Notification"

'Service_Create
    If Channel.ChannelsSupported Then
        Channel.Initialize(ChannelID, ChannelName, Channel.IMPORTANCE_HIGH)
        Channel.EnableLights = True
        Channel.EnableVibration = True
        Channel.Build
        Notification.Initialize(Channel.ID)
    Else
        Notification.Initialize(Null)
    End If

'Where you want (Don't need it all)
    Notification.SmallIcon = "icon"
    Notification.ContentTitle = "Title"
    Notification.ContentText = "Text"
    'Notification.setProgress(15, CounterTimer, False)
    Notification.DefaultVibrate = True
    Notification.DefaultSound = True
    Notification.DefaultLight = True
    Notification.Notify(1)

Enjoy...
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Peter --
Thanx. Result is absolutelly the same.
For test I used x86 emulator from Android Studio, API 26

In manifest:
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="26"/>
Path to android.jar : ...Sdk\platforms\android-27\android.jar

The problem here
B4X:
If Channel.ChannelsSupported Then
        ....
        Notification.Initialize(Channel.ID)  <----
    Else
        Notification.Initialize(Null)
    End If



B4X:
*** Service (firebasemessaging) Create ***
firebasemessaging_service_create (java line: 219)
java.lang.NoSuchMethodError: No direct method <init>(Landroid/content/Context;Ljava/lang/String;)V in class Landroid/support/v4/app/NotificationCompat$Builder; or its super classes (declaration of 'android.support.v4.app.NotificationCompat$Builder' appears in /data/app/com.quick.men-i_xy7FHnSH_XSPbBphiZOg==/base.apk)
    at uk.co.barxdroid.notificationbuilder.NotificationBuilder.Initialize(NotificationBuilder.java:96)
    at com.quick.men.firebasemessaging._service_create(firebasemessaging.java:219)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at com.quick.men.firebasemessaging.onCreate(firebasemessaging.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3404)
    at android.app.ActivityThread.-wrap4(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1683)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6541)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
 
Last edited:
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Erel --
I am not aware how to insert image. But I see exactly the same 27.1.1.

There are two problems with any built-in objects.
1) Not all features.
2) Unclear how it works.
For instance, built-in notification. How to set largeicon, if there is one icon only ?
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
- What is not clear ?

I tested built-in Nofication in Oreo 8.0.0. Works. This is nice, except large icon.

notificationbuilder (old library) also works (with adding a code, which creates a channel)
But for unclear reasons doesn't work correctly OnGoingEvent = False & AutoCancel = True. It's impossible to delete a message using "swipe to dismiss"
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
But for unclear reasons doesn't work correctly OnGoingEvent = False & AutoCancel = True. It's impossible to delete a message using "swipe to dismiss"
The default notification is not on going and can be dismissed with a swipe. I guess that you tried to dismiss a foreground notification.

Anyway if you have a question about the built-in notification object then please start a new thread.
 
Upvote 0

Similar Threads

Top