Android Question MyReceiver with NB6 error. MyReceiver_br (Solved)

jvrh_1

Active Member
Licensed User
I am trying to show a notificaction using two action buttons with NB6 library and Myreceiver module but when I compile, I get an error. ¿Some idea?

B4A:
B4A Versión: 11.80
Parseando código.    (0.15s)
    Java Versión: 11
Building folders structure.    (0.13s)
Compilando código.    (1.07s)
Compilado códigos de diseños.    (0.00s)
Organizando librerías.    (0.00s)
    (AndroidX SDK)
Compilando los recursos    (0.14s)
Enlazando los recursos    (0.56s)
Compilando el código del motor de depuración.    Error
B4A line: 58
n.AddButtonAction(SMILEY, \
shell\src\b4a\accesscontrol\firebasemessaging_subs_0.java:61: error: cannot find symbol
_n.runClassMethod (b4a.accesscontrol.nb6.class, "_addbuttonaction" /*RemoteObject*/ ,(Object)(_smiley),(Object)(RemoteObject.createImmutable(("Action 1"))),(Object)((firebasemessaging.mostCurrent._myreceiver.getObject())),(Object)(RemoteObject.createImmutable("action 1")));
                                                                                                                                                                                                               ^
  symbol:   method getObject()
  location: variable _myreceiver of type myreceiver
1 error

My code in Firebasemessaging when I received a notification:

B4X:
Sub fm_MessageArrived (Message As RemoteMessage)
    Log("Message arrived")
    Log($"Message data: ${Message.GetData}"$)
    
    Dim n As NB6
    Dim SMILEY As Bitmap
    SMILEY=LoadBitmap(File.DirAssets,"ICONO.png")
    n.Initialize("default", Application.LabelName, "DEFAULT").SmallIcon(SMILEY)
    n.AddButtonAction(SMILEY, "Action 1", MyReceiver, "action 1")
    Dim cs As CSBuilder
    n.AddButtonAction(Null, cs.Initialize.Color(Colors.Red).Bold.Append("Action 2").PopAll, MyReceiver, "action 2")
    n.DeleteAction(MyReceiver, "delete action")
    n.Build("Actions", "Actions", "tag", Main).Notify(1)

    
End Sub

Module Myreceiver
B4X:
Sub Process_Globals
    
End Sub

'Called when an intent is received.
'Do not assume that anything else, including the starter service, has run before this method.
Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
    If StartingIntent.IsInitialized Then
        Dim cs As CSBuilder
        cs.Initialize.Bold.Size(20).Append($"Action: ${StartingIntent.Action}"$).PopAll
        Log(cs)
        ToastMessageShow(cs, True)
    End If
End Sub

Thanks.
 

jvrh_1

Active Member
Licensed User
What's your manifest look like? Can you post up a sample app?
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="31"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
AddPermission(android.permission.INTERNET)
'End of default text.



'PARA NOTIFICACIONES Y AUTENTIFICAR EN LA APP CON GOOGLE
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseAuth.FirebaseAuth)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
SetApplicationAttribute(android:largeHeap,"true")
 
Upvote 0

jvrh_1

Active Member
Licensed User
I added to manifest this:

B4X:
AddPermission(android.permission.RECEIVE_BOOT_COMPLETED)
AddReceiverText(MyReceiver, <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>)

But I get an error:
"
Error parseando el script del manifiest.
El módulo myreceiver_br no se ha encontrado (Editor de manifiesto)"

In the NB6 example there is not a Service called "Starter", however in my project there is.
This is my Starter Service

B4X:
#Region  Service Attributes
    #StartAtBoot: False
    #ExcludeFromLibrary: True
#End Region

Sub Process_Globals
    Public rp As RuntimePermissions
End Sub

Sub Service_Create
    CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
End Sub

Sub Service_Start (StartingIntent As Intent)
    Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
End Sub

'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub Service_Destroy

End Sub
Sub Service_TaskRemoved
    'This event will be raised when the user removes the app from the recent apps list.
End Sub
 
Last edited:
Upvote 0
Top