Hi,
In my app I am using KVS to store the SMTP Server Detail etc. Inside the Activity_Create, I read the SMTP Server details from the KVS to a Map and then Initialize the SMTP object. Unfortunately, most of the time I get the Map Object not initialized error, it doesn't happen always. Once this starts to give error, then this is repeated, then I kill the app from the recent apps. Then it works.
Can anyone point me why this is happening only sometimes and not always. OR is there any other better way to achieve this
Here is the code that I use
I assume that it must be something wrong in the way that I am coding.
Any help will be appreciated.
Regards
Anser
In my app I am using KVS to store the SMTP Server Detail etc. Inside the Activity_Create, I read the SMTP Server details from the KVS to a Map and then Initialize the SMTP object. Unfortunately, most of the time I get the Map Object not initialized error, it doesn't happen always. Once this starts to give error, then this is repeated, then I kill the app from the recent apps. Then it works.
Can anyone point me why this is happening only sometimes and not always. OR is there any other better way to achieve this
Here is the code that I use
B4X:
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
#Extends: android.support.v7.app.AppCompatActivity
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private SMTP As SMTP
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Activity.Color=Colors.RGB(228,228,228)
ActionBar.Initialize("ActionBar")
Activity.AddView(ActionBar,0,0,100%x,56dip)
'Set the ToolBar (it is called ActionBar in the layout file) as the ActionBar of this activity.
ActionBar.SetAsActionBar
ActionBar.Title = "Login"
' Set the Toolbar Shadow
AC.SetElevation(ActionBar, 8dip)
ABHelper.Initialize
ABHelper.ShowUpIndicator = True
ActionBar.InitMenuListener
IME1.Initialize("IME1")
Dim MapSmtpDtls As Map
MapSmtpDtls.Initialize
MapSmtpDtls = Starter.kvs.GetEncrypted("SmtpDetails", "MyPassword")
If MapSmtpDtls.IsInitialized Then
SMTP.Initialize( MapSmtpDtls.Get("SmtpServer"), MapSmtpDtls.Get("SmtpPort"), MapSmtpDtls.Get("SmtpUserID"), MapSmtpDtls.Get("SmtpPassword"), "SMTP")
Else 'Most of the time the ELSE statement is executed ie Map is not initialized
ToastMessageShow("Email Map not initialized",False)
Activity.Finish
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
I assume that it must be something wrong in the way that I am coding.
Any help will be appreciated.
Regards
Anser