Android Question AddActivityText vs AddServiceText

Rusty

Well-Known Member
Licensed User
Longtime User
I'm trying to send text between two apps.
In DesolateSoul's tutorial, it is mentioned that you can use AddServiceText, but no further discussion.
I have AddActivityText working in my app, but the Activity for the Provider service comes to foreground and doesn't terminate without a BACK key touch. This is not desirable, so I'm thinking it would work better if the Requestor uses the a service to communicate.
What is the proper use of the AddServiceText and what SUB receives/sends the comms in both apps?
Thanks
Rusty
 

Rusty

Well-Known Member
Licensed User
Longtime User
thanks Erel,
So my main app manifest: (Should the MAIN be something else?)
AddReceiverText(Main, <intent-filter>
<action android:name="talkingsurvey.b4a.survey.CALLBACK" /> 'survey is my main app (activity)
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>)

my main app code:
B4X:
    Dim in As Intent
    in.Initialize("talkingsurvey.b4a.tsstart.REQUEST","")    'TSSTART is a widget (service)
    in.AddCategory("android.intent.category.DEFAULT")
    in.PutExtra("Callback","talkingsurvey.b4a.survey.CALLBACK")
    in.PutExtra("GetSettings", "True")
    in.PutExtra("Running", Toggle)
    Device.SendBroadcastIntent(in)
'    StartActivity(in)
my Widget service manifest:
AddActivityText(Main, <intent-filter>
<action android:name="talkingsurvey.b4a.tsstart.REQUEST" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>)

my widget service code:
B4X:
Sub Activity_Resume
    Dim in As Intent
    in = Activity.GetStartingIntent
    If in <> Null Then
        If in.HasExtra("GetSettings") Then
            Dim callback As String = in.GetExtra("Callback")
            Dim TSrunning As String = in.GetExtra("Running")
            WidgetService.isTSRunning = TSrunning = "True"
            LogColor("            PROVIDER: GetStartingIntent", Colors.Red)
            LogColor("                Came from: " & callback, Colors.red)
            LogColor("                RUNNING:    " & WidgetService.isTSRunning, Colors.red)
        End If
    End If   
   
    StartServiceAt(WidgetService, (DateTime.Now + (TickTime * DateTime.TicksPerSecond)), True)
    Activity.finish

End Sub

Your thoughts?
Rusty
 
Upvote 0
Top