I need to open the "Main" activity of my project "it.android.imgspa.and_StompClient", from a service of another app ""it.android.imgspa.and_StompClientService".
This is my service code:
The intent start activity gets me this:
What activity i have to declare? Where? How?
This is my service code:
B4X:
#Region Service Attributes
#StartAtBoot: True
#StartCommandReturnValue: android.app.Service.START_STICKY
#End Region
Sub Process_Globals
End Sub
Sub Service_Create
End Sub
Sub Service_Start (StartingIntent As Intent)
Try
If StartingIntent.HasExtra("android.intent.extra.ALARM_COUNT") Then
StartServiceAt("", TimeToNextSeconds (60), False)
Else
StartServiceAt("", TimeToNextSeconds (5), False)
End If
Catch
StartActivity(Main)
End Try
DateTime.DateFormat = "dd/MM/yyyy HH:MM:ss"
Log(DateTime.Date(DateTime.Now) & " hello")
StartStompClient
End Sub
Sub TimeToNextSeconds (aSeconds As Int)As Long
Dim ret As Long
Log("Service stars on " & aSeconds)
ret = DateTime.Now + DateTime.TicksPerSecond * aSeconds
ret = ret - (ret Mod DateTime.TicksPerSecond)
Return ret
End Sub
Private Sub StartStompClient
Dim Intent1 As Intent
Intent1.Initialize(Intent1.ACTION_MAIN, "")
Intent1.SetComponent("it.android.imgspa.and_StompClient/.Main")
Intent1.Flags = 33554432
StartActivity(Intent1)
End Sub
The intent start activity gets me this:
B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (stompclientservice) Create **
** Service (stompclientservice) Start **
Service stars on 5
22/10/2018 13:10:34 hello
android.content.ActivityNotFoundException: Unable to find explicit activity class {it.android.imgspa.and_StompClient/it.android.imgspa.and_StompClient.Main}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1634)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1430)
at android.app.ContextImpl.startActivity(ContextImpl.java:1173)
at android.app.ContextImpl.startActivity(ContextImpl.java:1148)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:311)
at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:686)
at it.android.imgspa.and_Stomp_Client_Service.stompclientservice._startstompclient(stompclientservice.java:155)
at it.android.imgspa.and_Stomp_Client_Service.stompclientservice._service_start(stompclientservice.java:139)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
at it.android.imgspa.and_Stomp_Client_Service.stompclientservice.handleStart(stompclientservice.java:68)
at it.android.imgspa.and_Stomp_Client_Service.stompclientservice.onStartCommand(stompclientservice.java:53)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2893)
at android.app.ActivityThread.access$2100(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1439)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5322)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
at dalvik.system.NativeStart.main(Native Method)
What activity i have to declare? Where? How?