Hi,
I made a simple app for receiving notifications. It worked well. After I intergrated the nb6 v1.01
Now I have the following problem, you can see in the screen shots.
Sometimes the font size of the views in the main layout is getting bigger when I click on a notfication
and the app opens. The icon of the notifcation is getting smaller and the text of all views bigger.
Code main:
FirebaseMessaging :
Starter:
I made a simple app for receiving notifications. It worked well. After I intergrated the nb6 v1.01
Now I have the following problem, you can see in the screen shots.
Sometimes the font size of the views in the main layout is getting bigger when I click on a notfication
and the app opens. The icon of the notifcation is getting smaller and the text of all views bigger.
Code main:
B4X:
Region Project Attributes
#ApplicationLabel: Central433 Control
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'Private Switch1 As Switch
Private lblMessage As Label
Private lv2 As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
End Sub
Sub Activity_Resume
End Sub
public Sub MessageFromFirebase(msg As String)
lv2.AddSingleLine(msg)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
FirebaseMessaging :
B4X:
#Region Module Attributes
'#StartAtBoot: False
#End Region
'Service module
'Version 0.9
Sub Process_Globals
'Dim sNotif As Notification
Private fm As FirebaseMessaging
End Sub
Sub Service_Create
fm.Initialize("fm")
End Sub
Public Sub SubscribeToTopics
fm.SubscribeToTopic("ios_general")
fm.SubscribeToTopic("alarm1")
End Sub
Sub Service_Start (StartingIntent As Intent)
If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
Sleep(0)
Service.StopAutomaticForeground 'remove if not using B4A v8+.
End Sub
'Sub fm_MessageArrived (Message As RemoteMessage)
' Log("Message arrived")
' Log($"Message data: ${Message.GetData}"$)
' Dim n As Notification
' n.Initialize
' n.Icon = "icon"
' n.Sound = True
' n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
'
' CallSubDelayed2(Main, "MessageFromFirebase",Message.GetData.Get("body") & " " & Message.GetData.Get("title"))
'
' n.Notify(1)
'End Sub
Sub fm_MessageArrived (Message As RemoteMessage)
Log("Message arrived")
Log($"Message data: ${Message.GetData}"$)
'n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
Dim rp As RuntimePermissions
Dim folder As String = rp.GetSafeDirDefaultExternal("shared")
Dim FileName As String = "shotgun.mp3"
'copy the file to the shared folder
File.Copy(File.DirAssets, FileName, folder, FileName)
Dim n As NB6
n.Initialize("custom sound", Application.LabelName, "HIGH")
n.SmallIcon(LoadBitmapResize(File.DirAssets, "logo_trans.png", 32dip, 32dip, True))
'disable the default sound
n.SetDefaults(False, True, True)
'set custom sound
n.CustomSound(CreateFileProviderUri(folder, FileName))
Dim Notification As Notification = n.Build(Message.GetData.Get("title"), Message.GetData.Get("body"), "", Main)
Notification.Notify(9)
CallSubDelayed2(Main, "MessageFromFirebase",Message.GetData.Get("body") & " " & Message.GetData.Get("title"))
End Sub
Sub CreateFileProviderUri (Dir As String, FileName As String) As Object
Dim FileProvider As JavaObject
Dim context As JavaObject
context.InitializeContext
FileProvider.InitializeStatic("android.support.v4.content.FileProvider")
Dim f As JavaObject
f.InitializeNewInstance("java.io.File", Array(Dir, FileName))
Return FileProvider.RunMethod("getUriForFile", Array(context, Application.PackageName & ".provider", f))
End Sub
Starter:
B4X:
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
' Public sNotif As Notification
End Sub
Sub Service_Create
' sNotif.Initialize
' sNotif.Icon = "icon"
' 'sNotif.Sound = False
'
'
'
'
' sNotif.SetInfo("JK Central433","Service Running",Main)
' 'sNotif.Notify(1)
CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
End Sub
Sub Service_Start (StartingIntent As Intent)
' Sleep(0)
' Service.StopAutomaticForeground
' Service.StartForeground(1,sNotif)
End Sub
Sub Service_Destroy
Log("Service destroyed")
End Sub