B4A Library SD: Floating Button StandOut

DonManfred

Expert
Licensed User
Longtime User
close the notification in the status bar?
i dont think as the notification is a notification for a foregroundservice. Stop the foregroundservice to remove the icon.
Stopping the foreground service stops the Standout-feature too so it would make the lib useless.
 

diegoferreira

Member
Licensed User
Longtime User
sorry, i mean set it invisible or edit it.. i'm trying to make a custom notification for my app, but when the floating is active it show me 2 notifications in the status bar.

Thanks.
 

Star-Dust

Expert
Licensed User
Longtime User
Now I'm on vacation, just come back I'll make the customizable notification image. As explained by Don Manfred, it can not be eliminated because the service could otherwise be killed
 

Star-Dust

Expert
Licensed User
Longtime User
Here you find the original code, if you delete the service the button will no longer float point.
but if you can do it you can do your own update of the library

I came back next week
 

Shivito1

Active Member
Licensed User
The examples work but when I try to add it to my existing app I get error.

Here is the error:

B4X:
java.lang.RuntimeException: Unable to start service b4a.example.standout@60cdb94 with Intent { cmp=com.subreaderFree/b4a.example.standout launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } }: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3755)
    at android.app.ActivityThread.-wrap23(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1744)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6780)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:216)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:163)
    at b4a.example.standout.handleStart(standout.java:113)
    at b4a.example.standout.onStartCommand(standout.java:81)
    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3738)
    ... 8 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
    at b4a.example.standout._init_elements(standout.java:314)
    at b4a.example.standout._service_start(standout.java:552)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:179)
    ... 12 more
Caused by: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@b54dda6 -- permission denied for window type 2002
    at android.view.ViewRootImpl.setView(ViewRootImpl.java:921)
    at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:97)
    at b4a.example.standout$CustomImageView.sharedConstructing(standout.java:633)
    at b4a.example.standout$CustomImageView.<init>(standout.java:604)
    at b4a.example.standout.newInstance2(standout.java:771)
    ... 18 more
** Service (standout) Create **
java.io.FileNotFoundException: icon.png
    at android.content.res.AssetManager.openAsset(Native Method)
    at android.content.res.AssetManager.open(AssetManager.java:423)
    at android.content.res.AssetManager.open(AssetManager.java:397)
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:202)
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:500)
    at anywheresoftware.b4a.keywords.Common.LoadBitmap(Common.java:1160)
    at b4a.example.standout._service_create(standout.java:479)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:179)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:163)
    at b4a.example.standout.onCreate(standout.java:66)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3531)
    at android.app.ActivityThread.-wrap6(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1729)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6780)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
java.lang.RuntimeException: Unable to create service b4a.example.standout: java.lang.RuntimeException: java.io.FileNotFoundException: icon.png
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3541)
    at android.app.ActivityThread.-wrap6(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1729)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6780)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: icon.png
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:216)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:163)
    at b4a.example.standout.onCreate(standout.java:66)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3531)
    ... 8 more
Caused by: java.io.FileNotFoundException: icon.png
    at android.content.res.AssetManager.openAsset(Native Method)
    at android.content.res.AssetManager.open(AssetManager.java:423)
    at android.content.res.AssetManager.open(AssetManager.java:397)
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:202)
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:500)
    at anywheresoftware.b4a.keywords.Common.LoadBitmap(Common.java:1160)
    at b4a.example.standout._service_create(standout.java:479)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:179)
    ... 11 more
 

Star-Dust

Expert
Licensed User
Longtime User
Set a image file.
B4X:
FloatingStandOut.PathImage=File.DirAssets
FloatingStandOut.NameFileImage="imagename.png"
 

Star-Dust

Expert
Licensed User
Longtime User
0.05 release update
Handles special permission requests from the SDK23 + and other changes for SDK26 +

Add this method:
  • GetPermission As Boolean ' Verify special permission - SDK 23+
  • SDK_Version As int ' Get SDK version
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
0.06 release update
Handles special permission requests from the SDK23 + and other changes for SDK26 +

Add this method:
  • GetPermission As Boolean ' Verify special permission - SDK 23+
  • SDK_Version As int' Get SDK version
  • OpenSettingPermission ' Opening setting permission panel
  • ActivatePermissionResumable ' Check the permissions, open the setting panel if there are no permissions.
    Use resumable sub, then return control to the app while waiting for the setting result

request permission SDK 23+
B4X:
    Dim Permission As SpecialPermission
    Permission.Initialize
    If Permission.GetPermission Then
        FloatingStandOut.Start(Me)
    Else
        Permission.OpenSettingPermission
    End If

With resumable sub
B4X:
Sub RequestPermission
    Dim Permission As SpecialPermission
    Permission.Initialize
    Log(Permission.GetPermission)
    Wait For (Permission.ActivatePermissionResumable) Complete (Success As Boolean)
    If Success Then    FloatingStandOut.Start(Me)
End Sub
 
Last edited:

sseaand

Member
Licensed User
Longtime User
I have the error java.lang.RuntimeException: Cannot change properties after call to SetInfo. Initialize the notification again.
 

Star-Dust

Expert
Licensed User
Longtime User
Have you downloaded the latest version?
 

sseaand

Member
Licensed User
Longtime User
Yes, version 0.06. And can you add notification options, to disable it or change notification text?
 

Star-Dust

Expert
Licensed User
Longtime User
Yes, version 0.06. And can you add notification options, to disable it or change notification text?
No, notification is necessary. I will see in the next update if you can customize the message.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…