Android Tutorial [TUTORIAL] Inter-app Communication with Intents

wenzelww

Member
Licensed User
Longtime User
Just wanted to let you know that I could find a working solution inside the Wearable Datalayer threat:

static - More complex but means you can receive messages at any time
Add the following text to the Manifest Editor
<code>AddApplicationText(
<service android:name="barxdroid.wearabledatalayer.ListenerService"
android:label="Wearable Listener">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>)
</code>
Then add a service called 'WearListenerService to your project and in the service module, use code like this.
<code>
Sub Process_Globals
Dim WL As WearableListener
End Sub
Sub Service_Start (StartingIntent As Intent)
WL.Initialize("WL")
WL.HandleIntent(StartingIntent)
End Sub
Sub WL_MessageReceived(SourceNodeID As String, RequestID As Int, msgPath As String, Data As String)
ToastMessageShow(Data, False)
End Sub
</code>


Wilhelm
 

brunnlechner

Member
Licensed User
Longtime User
Hello,
if I change to android:targetSdkVersion="26", I get the error:

java.lang.IllegalArgumentException: Service Intent must be explicit: Intent....


B4X:
    Dim in As Intent
    in.Initialize("thisapp.b4a.intentprovider.REQUEST","")
    StartService(in)


Franz
 
Last edited:

brunnlechner

Member
Licensed User
Longtime User
B4X:
in.SetPackage("provider.app")
'assuming that this is the target app package name

Thanks Erel, you're the best - that's how it works perfectly again.
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…