Can MainActivity behave the way a WearableListenerService does in Android/Wear OS-ThrowExceptions

Exception or error:

My WearDataLayerListenerService which extends WearableListenerService gets onDataChanged events when the wearable app is closed. I either need to pass a photo asset from the WearDataLayerListenerService to the MainActivity or find a way to make the MainActivity behave the way the WearDataLayerListenerService. Does anybody know if this is possible? I thought passing around a photo asset would not be very efficient.

My manifest looks like this:

<meta-data
    android:name="com.google.android.wearable.standalone"
    android:value="false"/>
<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:launchMode="singleTask">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

<service
    android:name=".WearDataLayerListenerService"
    android:enabled="true"
    android:exported="true">
    <intent-filter>
        <action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
        <action android:name="com.google.android.gms.wearable.MESSAGE_RECEIVED" />
        <data android:scheme="wear" android:host="*" android:pathPrefix="/start-activity" />
        <data android:scheme="wear" android:host="*" android:pathPrefix="/message/mobile" />
    </intent-filter>
</service>
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *