The steps needed to implement this functionality depends on whether the notification is submitted from phone or from wearable device.
Notification from phone:
If your notification came from phone - the "Open on phone" action page is added automatically when your notification has setContentIntent(PendingIntent intent) set.
From your wearable app:
If you need to play this animation in a notification that is submitted from wearable device directly (or from any other place from your wearable application) you will need to launch this animation by yourself.
There is a nice ConfirmationActivity
that supports few predefined animation types:
ConfirmationActivity.SUCCESS_ANIMATION
ConfirmationActivity.OPEN_ON_PHONE_ANIMATION
ConfirmationActivity.FAILURE_ANIMATION
The animation you should be interested it is ConfirmationActivity.OPEN_ON_PHONE_ANIMATION
. You need to pass the type of animation in the ConfirmationActivity.EXTRA_ANIMATION_TYPE
extra.
Intent intent = new Intent(context, ConfirmationActivity.class);
intent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, ConfirmationActivity.OPEN_ON_PHONE_ANIMATION);
startActivity(intent);
IMPORTANT:
To launch the ConfirmationActivity
you need to add it to your Manifest file:
<activity android:name="android.support.wearable.activity.ConfirmationActivity" />
Theme:
Next step is to tweak the style of this ConfirmationActivity
. For example if you want to disable the default sliding animation or to make the window transparent you will need to set a custom theme to it in your manifest:
<activity android:name="android.support.wearable.activity.ConfirmationActivity"
android:theme="@style/TransparentTheme"/>
and define the TransparentTheme
in themes.xml
:
<style name="TransparentTheme" parent="@android:style/Theme.DeviceDefault">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@null</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
</style>