B4A Library SD: Floating Button StandOut

(No WRAP, but B4A)
I've been in a new challenge. I reworked a little release published by @JordiCP. Find Here

He entered the Java code taken by GitHub (see https://github.com/henrychuangtw/Android-ChatHead) and wrapped it with "#IF JAVA" inside a B4A module.

With his permission I extended a bit of the B4A code and retouched the Java code (for that little I remember Java) and I realized one thing I longed for: A flying button that always stands out even on other Apps On the Desktop.

You can get the full version by making a donation..

SD_FloatingStandOut

Author:
Star-Dust
Version: 0.09
  • FloatingStandOut
    Code module
    Subs in this code module will be accessible from all modules.
    • Fields:
      • ActiveService As Boolean
      • ENABLEDROP As Boolean
      • EventClick As String
      • EventDoubleClick As String
      • EventLongClick As String
      • EventMove As String
      • HALF_STICK_TO_BORDER As Boolean
      • HeightImage As Int
      • NameFileImage As String
      • NotificationBody As String
      • NotificationTitle As String
      • PathImage As String
      • StartActivity_OnClick As Boolean
      • StartActivity_OnDoubleClick As Boolean
      • StartActivity_OnLongClick As Boolean
      • STICK_TO_BORDER As Boolean
      • StopFloating_OnClick As Boolean
      • StopFloating_OnDoubleClick As Boolean
      • StopFloating_OnLongClick As Boolean
      • WhiteCircle As Boolean
      • WidthImage As Int
      • X As Int
      • Y As Int
    • Functions:
      • Process_Globals As String
      • SetEvent (EventName As String) As String
        SetEvent("FL")
        Sub FL_OnClick(X as int, Y as int)
        Sub FL_OnDoubleClick(X as int, Y as int)
        Sub FL_OnLongClick(X as int, Y as int)
        Sub FL_OnMove(X as int, Y as int)
      • SetImageBitmap (img As Bitmap) As String
      • SetStartActivity (OnClick As Boolean, OnDoubleClick As Boolean, OnLongClick As Boolean) As String
      • SetStopFloating (OnClick As Boolean, OnDoubleClick As Boolean, OnLongClick As Boolean) As String
      • Start (Me_CallBack As Object) As String
        Es. Start(Me,Application.PackageName)
      • Stop As String
  • SpecialPermission
    • Functions:
      • ActivatePermissionResumable As ResumableSub
      • Class_Globals As String
      • GetPermission As Boolean
      • Initialize As String
        Inizializza l'oggetto. Puoi aggiungere parametri a questo metodo,se necessario.
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • OpenSettingPermission As String
      • SdkVersion As Int
  • chElement
    • Fields:
      • active As Boolean
      • id As Int
      • instance As JavaObject
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • ttype As chType
      • xpos As Int
      • ypos As Int
    • Functions:
      • Initialize
        Inizializza i campi al loro valore predefinito.
  • standout
    • Fields:
      • CallBack As Object
      • Snotif As Notification
    • Functions:
      • process_globals


N.B. Don't forget ADD to Manifest
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

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
 

Attachments

  • sample1.zip
    48.5 KB · Views: 1,080
  • sample2.zip
    26.8 KB · Views: 1,137
  • SD_FloatingStandOut 0.09.zip
    21.2 KB · Views: 337
Last edited:

Marcos Alves

Well-Known Member
Licensed User
Longtime User
(No WRAP, but B4A)

I've been in a new challenge. I reworked a little release published by @JordiCP. Find Here

He entered the Java code taken by GitHub (see https://github.com/henrychuangtw/Android-ChatHead) and wrapped it with "#IF JAVA" inside a B4A module.

With his permission I extended a bit of the B4A code and retouched the Java code (for that little I remember Java) and I realized one thing I longed for: A flying button that always stands out even on other Apps On the Desktop.

I hope that's what I'm excited about how I was excited about me.

FloatingStandOut
Author:
Star-Dust
Version: 0.06
  • FloatingStandOut
    Fields:
    • ActiveService As Boolean
    • stick_to_border As Boolean
    • half_stick_to_border As Boolean
    • WhiteCircle As Boolean
    • PathImage As String
    • NameFileImage As String
    • HeightImage As Int
    • WidthImage As Int
    • x As Int
    • y As Int
    Methods:
    • process_globals As String
    • SetEvent (EventName As String) As String
      SetEvent("FL")
      Sub FL_OnClick(X as int, Y as int)
      Sub FL_OnDoubleClick(X as int, Y as int)
      Sub FL_OnLongClick(X as int, Y as int)
      Sub FL_OnMove(X as int, Y as int)
    • SetImageBitmap(img As Bitmap)
      ' Change image
    • SetStartActivity (OnClick As Boolean, OnDoubleClick As Boolean, OnLongClick As Boolean) As String
    • SetStopFloating (OnClick As Boolean, OnDoubleClick As Boolean, OnLongClick As Boolean) As String
    • Start (Me_CallBack As Object) As String
      Es. Start(Me,Application.PackageName)
    • Stop As String
  • SpecialPermission
    Methods:
    • 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
N.B. Don't forget ADD to Manifest
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>


Hello ! I'm getting the error:

java.lang.RuntimeException: Unable to create service b4a.example.standout: java.lang.RuntimeException: java.lang.RuntimeException: Cannot change properties after call to SetInfo. Initialize the notification again.

any suggestion?
 

Star-Dust

Expert
Licensed User
Longtime User
Hello ! I'm getting the error:

java.lang.RuntimeException: Unable to create service b4a.example.standout: java.lang.RuntimeException: java.lang.RuntimeException: Cannot change properties after call to SetInfo. Initialize the notification again.

any suggestion?
A notification is created to keep the service always active.
Com Android 8 (and B4A 8) Notifications have changed the last call after creating a notification must be with SetInfo.
(see https://www.b4x.com/android/forum/threads/b4a-v8-0-has-been-released.90828/)

If you report this error it means that you have changed something in the code so that notifications are changed after the SetInfo.
do you use B4A 8?
do you use the latest version of the notification library?
Do you use the latest version of the library?

show the code that generates the error so check
 

Marcos Alves

Well-Known Member
Licensed User
Longtime User
A notification is created to keep the service always active.
Com Android 8 (and B4A 8) Notifications have changed the last call after creating a notification must be with SetInfo.
(see https://www.b4x.com/android/forum/threads/b4a-v8-0-has-been-released.90828/)

If you report this error it means that you have changed something in the code so that notifications are changed after the SetInfo.
do you use B4A 8?
do you use the latest version of the notification library?
Do you use the latest version of the library?

show the code that generates the error so check
Hi,

I found that it's occurring in debug mode. If the app is compiled runs normally . The lib version is 0.06

The code is your sample1 without changes.

UPDATE: Only Sample2 is running after compiled. Sample1 and Sample2 don't run in debug mode.
Error is:
java.lang.RuntimeException: Cannot change properties after call to SetInfo. Initialize the notification again.
 

Star-Dust

Expert
Licensed User
Longtime User
Do you use legacy debugging?
 

Marcos Alves

Well-Known Member
Licensed User
Longtime User
No. I'm using default debugging... B4A V 7.30
upload_2018-6-5_11-39-12.png


upload_2018-6-5_11-39-50.png
 

Star-Dust

Expert
Licensed User
Longtime User

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Then you have to make a change to the library, because it is compiled with B4A 8.0.

For previous versions you have to follow this
https://www.b4x.com/android/forum/threads/version-safe-notification.87663/
Thanks! I upgraded to V8 a week ago but had to rollback because there was a bug in Firebase Notifications, that I use... @Erel fixed the bug on sunday :))) but at that time I had already rolled back and, as I need to finish a project, hadn't time up to now to try V8 again...
But, by the way: how can I change the lib to run in V7.30?
 

Star-Dust

Expert
Licensed User
Longtime User
Thanks! I upgraded to V8 a week ago but had to rollback because there was a bug in Firebase Notifications, that I use... @Erel fixed the bug on sunday :))) but at that time I had already rolled back and, as I need to finish a project, hadn't time up to now to try V8 again...
But, by the way: how can I change the lib to run in V7.30?
I should do it as soon as I have the time, now I'm off-site and I'll probably be able to work on the PC over the weekend
 

peacemaker

Expert
Licensed User
Longtime User
B4A 8.3. samples does not work under Android 5. LIb v.0.06
B4X:
java.lang.RuntimeException: Unable to create service b4a.example.standout: java.lang.RuntimeException: java.lang.RuntimeException: Cannot change properties after call to SetInfo. Initialize the notification again.

Notification code must be fixed\re-compiled in the lib :(
 

Star-Dust

Expert
Licensed User
Longtime User
The error indicated and related to the notifications. From version B4A 8+ SetInfo must be called last.

As soon as I return to the office, I will check. But it has already been tested on Android 8.0 devices.

Are you using the attached example?
 

Star-Dust

Expert
Licensed User
Longtime User
Which device are you trying on? what version of Android do you use? What is the target SDK?
 

peacemaker

Expert
Licensed User
Longtime User
MEMU emulator Android 5.1.1, your samples projects with android:targetSdkVersion="26".
In Google emulator Android 8.1 the same.
Debug mode, or release - the same.
 

Star-Dust

Expert
Licensed User
Longtime User
MEMU emulator Android 5.1.1, your samples projects with android:targetSdkVersion="26".
In Google emulator Android 8.1 the same.
Debug mode, or release - the same.
Probably the problem was that I had not published the update. :D
Try with version 0.07.
On my Android 8.0 device it works properly

Example 2 opens a circular menu after clicking on the Head
 

peacemaker

Expert
Licensed User
Longtime User
Indeed, was forgotten :)
v.0.07 works good ! THANKS

p.s. but the menu position is to be adjusted, sometimes it's centered, not around the head position.
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Indeed, was forgotten :)
v.0.07 works good ! THANKS

p.s. but the menu position is to be adjusted, sometimes it's centered, not around the head position.
I had updated the examples for the new version but not the library. :confused::confused:
 

peacemaker

Expert
Licensed User
Longtime User
But is there way to use instead of imageview - Editview as the topmost view ?
 

Star-Dust

Expert
Licensed User
Longtime User
Yes, of course, but not with my library.
@JordiCP has developed a library that makes a floating panel.
Or through the Java code that shared @JordiCP and modify it you can get any view that fluctuates.

Of course EditText is a very special sight that already absorbs many touch events, so it requires careful design
 
Top