Android Question How to start layout from service ?

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

My app have two layout(Main,chat), one service. the service will start into background when i run this app. How could i load(start) Activity(Main or chat) to show message from service when i close all layout and then service has received some mqtt message later ?

B4X:
, status=7, IsInitialized=true, value=200
]
** Activity (main) Pause, UserClosed = false **
** Activity (chat) Create, isFirst = false **
** Activity (chat) Resume **
** Activity (chat) Pause, UserClosed = true **
client disconnected
** Activity (main) Resume **
Mqtt:reconnecting...
Connected: true
** Activity (main) Pause, UserClosed = true **
topiciot/plc1/2222,[topic=iot/plc1/2222, message=正常200, happen=1463530515454
, status=0, IsInitialized=true, value=200
]
sending message to waiting queue (CallSubDelayed - NewMessage)  <<<<---------- all layout were close
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
topiciot/plc1/2222,[topic=iot/plc1/2222, message=過高8, happen=1463530559482
, status=8, IsInitialized=true, value=200
]
** Activity (main) Pause, UserClosed = false **
GC_CONCURRENT freed 385K, 16% free 12370K/14663K, paused 3ms+1ms, total 35ms
** Activity (chat) Create, isFirst = false **
running waiting messages (1)
** Activity (chat) Resume **
** Activity (chat) Pause, UserClosed = false **
 
Last edited:

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

I could startactivity(chat) to show message when i close all activity and then receive mqtt message later.
my main activity is a login form. How to jumping main activity to chat activity because service always running in background and MQTT connected when i click APP again ?

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")       <<-- Jumping to chat activity
    txtAccount.Text=""
    txtPassword.Text=""
    chkService.Checked=False
    StateManager.RestoreState(Activity, "Main", 0)      
End Sub
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…