Search code examples
androidandroid-notificationswear-os

Android Wearable app with no Activity


I'm creating a wear app that is used to extend my handheld app's notifications. I wrote a wear module (a separate wear app) because I needed my handheld and wearable devices to behave differently with their notifications.

By creating a separate app for wear, it can now be launched on my wear device (by default, I get the Activity saying "Hello Square World!").

Is there a way for my wear app to exists without the option to launch it?


Solution

  • As tyczj stated you don't need an activity if you are using service.

    To be able to run/debug this via Android Studio you must edit the Run/Debug configuration for the wear app and specify "Do not launch activity" under the Activity section.

    Here's a sample of my manifest, it's just a wear listener service.

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="org.codechimp.myapp" >
    
        <uses-permission android:name="android.permission.VIBRATE" />
        <uses-feature android:name="android.hardware.type.watch" />
    
        <application
            android:allowBackup="true"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.DeviceDefault" >
    
            <service android:name=".WearListenerService">
                <intent-filter>
                    <action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
                </intent-filter>
            </service>
    
            <meta-data
                android:name="com.google.android.gms.version"
                android:value="@integer/google_play_services_version" />
        </application>
    
    </manifest>