original source : http://www.androiddocs.com/training/wearables/ui/lists.html

Creating Lists

Lists let users select an item from a set of choices easily on wearable devices.

The Wearable UI Library includes the WearableListView class .

To create a list in your Android Wear apps:

  1. Add a WearableListView element to your activity’s layout definition.
  2. Create a custom layout implementation for your list items.
  3. Use this implementation to create a layout definition file for your list items.
  4. Create an adapter to populate the list.
  5. Assign the adapter to the WearableListView element

Add a List View

<android.support.wearable.view.BoxInsetLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   android:background="@drawable/robot_background"
   android:layout_height="match_parent"
   android:layout_width="match_parent">

   <FrameLayout
       android:id="@+id/frame_layout"
       android:layout_height="match_parent"
       android:layout_width="match_parent"
       app:layout_box="left|bottom|right">

       <android.support.wearable.view.WearableListView
           android:id="@+id/wearable_list"
           android:layout_height="match_parent"
           android:layout_width="match_parent">
       </android.support.wearable.view.WearableListView>
   </FrameLayout>
</android.support.wearable.view.BoxInsetLayout>



Create a Layout Implementation for List Items

This layout also implements the methods in the WearableListView.OnCenterProximityListener interface to change the color of the item’s icon and fade the text in response to events from WearableListView as the user scrolls through the list.

public class WearableListItemLayout extends LinearLayout
            implements WearableListView.OnCenterProximityListener {

   private ImageView mCircle;
   private TextView mName;

   private final float mFadedTextAlpha;
   private final int mFadedCircleColor;
   private final int mChosenCircleColor;

   public WearableListItemLayout(Context context) {
       this(context, null);
   }

   public WearableListItemLayout(Context context, AttributeSet attrs) {
       this(context, attrs, 0);
   }

   public WearableListItemLayout(Context context, AttributeSet attrs,
                                 int defStyle) {
       super(context, attrs, defStyle);

       mFadedTextAlpha = getResources()
                        .getInteger(R.integer.action_text_faded_alpha) / 100f;
       mFadedCircleColor = getResources().getColor(R.color.grey);
       mChosenCircleColor = getResources().getColor(R.color.blue);
   }

   // Get references to the icon and text in the item layout definition
   @Override
   protected void onFinishInflate() {
       super.onFinishInflate();
       // These are defined in the layout file for list items
       // (see next section)
       mCircle = (ImageView) findViewById(R.id.circle);
       mName = (TextView) findViewById(R.id.name);
   }

   @Override
   public void onCenterPosition(boolean animate) {
       mName.setAlpha(1f);
       ((GradientDrawable) mCircle.getDrawable()).setColor(mChosenCircleColor);
   }

   @Override
   public void onNonCenterPosition(boolean animate) {
       ((GradientDrawable) mCircle.getDrawable()).setColor(mFadedCircleColor);
       mName.setAlpha(mFadedTextAlpha);
   }
}



Create a Layout Definition for Items

res/layout/list_item.xml

<com.example.android.support.wearable.notifications.WearableListItemLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:gravity="center_vertical"
   android:layout_width="match_parent"
   android:layout_height="80dp">
   <ImageView
       android:id="@+id/circle"
       android:layout_height="20dp"
       android:layout_margin="16dp"
       android:layout_width="20dp"
       android:src="@drawable/wl_circle"/>
   <TextView
       android:id="@+id/name"
       android:gravity="center_vertical|left"
       android:layout_width="wrap_content"
       android:layout_marginRight="16dp"
       android:layout_height="match_parent"
       android:fontFamily="sans-serif-condensed-light"
       android:lineSpacingExtra="-4sp"
       android:textColor="@color/text_color"
       android:textSize="16sp"/>
</com.example.android.support.wearable.notifications.WearableListItemLayout>



Create an Adapter to Populate the List

private static final class Adapter extends WearableListView.Adapter {
   private String[] mDataset;
   private final Context mContext;
   private final LayoutInflater mInflater;

   // Provide a suitable constructor (depends on the kind of dataset)
   public Adapter(Context context, String[] dataset) {
       mContext = context;
       mInflater = LayoutInflater.from(context);
       mDataset = dataset;
   }

   // Provide a reference to the type of views you're using
   public static class ItemViewHolder extends WearableListView.ViewHolder {
       private TextView textView;
       public ItemViewHolder(View itemView) {
           super(itemView);
           // find the text view within the custom item's layout
           textView = (TextView) itemView.findViewById(R.id.name);
       }
   }

   // Create new views for list items
   // (invoked by the WearableListView's layout manager)
   @Override
   public WearableListView.ViewHolder onCreateViewHolder(ViewGroup parent,
                                                         int viewType) {
       // Inflate our custom layout for list items
       return new ItemViewHolder(mInflater.inflate(R.layout.list_item, null));
   }

   // Replace the contents of a list item
   // Instead of creating new views, the list tries to recycle existing ones
   // (invoked by the WearableListView's layout manager)
   @Override
   public void onBindViewHolder(WearableListView.ViewHolder holder,
                                int position) {
       // retrieve the text view
       ItemViewHolder itemHolder = (ItemViewHolder) holder;
       TextView view = itemHolder.textView;
       // replace text contents
       view.setText(mDataset[position]);
       // replace list item's metadata
       holder.itemView.setTag(position);
   }

   // Return the size of your dataset
   // (invoked by the WearableListView's layout manager)
   @Override
   public int getItemCount() {
       return mDataset.length;
   }
}



Associate the Adapter and Set a Click Listener

public class WearActivity extends Activity
                         implements WearableListView.ClickListener {

   // Sample dataset for the list
   String[] elements = { "List Item 1", "List Item 2", ... };

   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.my_list_activity);

       // Get the list component from the layout of the activity
       WearableListView listView =
           (WearableListView) findViewById(R.id.wearable_list);

       // Assign an adapter to the list
       listView.setAdapter(new Adapter(this, elements));

       // Set a click listener
       listView.setClickListener(this);
   }

   // WearableListView click listener
   @Override
   public void onClick(WearableListView.ViewHolder v) {
       Integer tag = (Integer) v.itemView.getTag();
       // use this data to complete some action ...
   }

   @Override
   public void onTopEmptyRegionClick() {
   }
}

original source: http://www.androiddocs.com/training/wearables/notifications/pages.html

Adding Pages to a Notification

additional pages appear immediately to the right of the main notification card.

To create a notification with multiple pages:

  1. Create the main notification (the first page) with NotificationCompat.Builder, in the way you’d like the notification to appear on a handset.
  2. Create the additional pages for the wearable with NotificationCompat.Builder.
  3. Apply the pages to the main notification with the addPage() method or add multiple pages in a Collectionwith the addPages() method.

// Create builder for the main notification
NotificationCompat.Builder notificationBuilder =
       new NotificationCompat.Builder(this)
       .setSmallIcon(R.drawable.new_message)
       .setContentTitle("Page 1")
       .setContentText("Short message")
       .setContentIntent(viewPendingIntent);

// Create a big text style for the second page
BigTextStyle secondPageStyle = new NotificationCompat.BigTextStyle();
secondPageStyle.setBigContentTitle("Page 2")
              .bigText("A lot of text...");

// Create second page notification
Notification secondPageNotification =
       new NotificationCompat.Builder(this)
       .setStyle(secondPageStyle)
       .build();

// Extend the notification builder with the second page
Notification notification = notificationBuilder
       .extend(new NotificationCompat.WearableExtender()
               .addPage(secondPageNotification))
       .build();

// Issue the notification
notificationManager =
       NotificationManagerCompat.from(this);
notificationManager.notify(notificationId, notification);

original source :http://www.androiddocs.com/training/wearables/notifications/voice-input.html

Receiving Voice Input in a Notification

If you have handheld notifications that include an action to input text, such as reply to an email, it should normally launch an activity on the handheld device to input the text. However, when your notification appears on a wearable, there is no keyboard input, so you can let users dictate a reply or provide pre-defined text messages using RemoteInput.

When users reply with voice or select one of the available messages, the system attaches the text response to the Intentyou specified for the notification action and sends that intent to your handheld app.

Define the Voice Input

To create an action that supports voice input, create an instance of

RemoteInput.Builder

that you can add to your notification action. This class’s constructor accepts a string that the system uses as the key for the voice input, which you’ll later use to retrieve the text of the input in your handheld app.For example, here’s how to create a

RemoteInput

object that provides a custom label for the voice input prompt:

// Key for the string that's delivered in the action's intent
private static final String EXTRA_VOICE_REPLY = "extra_voice_reply";

String replyLabel = getResources().getString(R.string.reply_label);

RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
       .setLabel(replyLabel)
       .build();



Add Pre-defined Text Responses

setChoices()

res/values/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
   <string-array name="reply_choices">
       <item>Yes</item>
       <item>No</item>
       <item>Maybe</item>
   </string-array>
</resources>
public static final String EXTRA_VOICE_REPLY = "extra_voice_reply";
...
String replyLabel = getResources().getString(R.string.reply_label);
String[] replyChoices = getResources().getStringArray(R.array.reply_choices);

RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
       .setLabel(replyLabel)
       .setChoices(replyChoices)
       .build();



Add the Voice Input as a Notification Action

// Create an intent for the reply action
Intent replyIntent = new Intent(this, ReplyActivity.class);
PendingIntent replyPendingIntent =
       PendingIntent.getActivity(this, 0, replyIntent,
               PendingIntent.FLAG_UPDATE_CURRENT);

// Create the reply action and add the remote input
NotificationCompat.Action action =
       new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon,
               getString(R.string.label), replyPendingIntent)
               .addRemoteInput(remoteInput)
               .build();

// Build the notification and add the action via WearableExtender
Notification notification =
       new NotificationCompat.Builder(mContext)
               .setSmallIcon(R.drawable.ic_message)
               .setContentTitle(getString(R.string.title))
               .setContentText(getString(R.string.content))
               .extend(new WearableExtender().addAction(action))
               .build();

// Issue the notification
NotificationManagerCompat notificationManager =
       NotificationManagerCompat.from(mContext);
notificationManager.notify(notificationId, notification);

Receiving the Voice Input as a String

(notification은 sync와는 달리 일방통행이라고 하지만 reply action intent를 통해 reply message를 전달 받을수 있다. )

To receive the user’s transcribed message in the activity you declared in the reply action’s intent, call

getResultsFromIntent()

, passing in the “Reply” action’s intent. This method returns a

Bundle

that contains the text response. You can then query the

Bundle

to obtain the response.

Note:

Do not use

Intent.getExtras()

to obtain the voice result, because the voice input is stored as

ClipData

. The

getResultsFromIntent()

method provides a convenient way to receive a character sequence without having to process the

ClipData

yourself.

/**
* Obtain the intent that started this activity by calling
* Activity.getIntent() and pass it into this method to
* get the associated voice input string.
*/

private CharSequence getMessageText(Intent intent) {
   Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
   if (remoteInput != null) {
       return remoteInput.getCharSequence(EXTRA_VOICE_REPLY);
   }
   return null;
}

original source : http://www.androiddocs.com/training/wearables/notifications/creating.html

Creating a Notification for Wearables

NotificationCompat.Builder 을 사용하면 기본적으로 mobile, wearable 기기에 전달될 기본 notification을 만들수 있다.



Import the necessary classes

build.gradlefile:

compile "com.android.support:support-v4:20.0.+"
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.app.NotificationCompat.WearableExtender;



Create Notifications with the Notification Builder

int notificationId = 001;
// Build intent for notification content
Intent viewIntent = new Intent(this, ViewEventActivity.class);
viewIntent.putExtra(EXTRA_EVENT_ID, eventId);
PendingIntent viewPendingIntent =
       PendingIntent.getActivity(this, 0, viewIntent, 0);

NotificationCompat.Builder notificationBuilder =
       new NotificationCompat.Builder(this)
       .setSmallIcon(R.drawable.ic_event)
       .setContentTitle(eventTitle)
       .setContentText(eventLocation)
       .setContentIntent(viewPendingIntent);

// Get an instance of the NotificationManager service
NotificationManagerCompat notificationManager =
       NotificationManagerCompat.from(this);

// Build the notification and issues it with notification manager.
notificationManager.notify(notificationId, notificationBuilder.build());

When this notification appears on a handheld device, the user can invoke the PendingIntent specified by the setContentIntent() method by touching the notification. When this notification appears on an Android wearable, the user can swipe the notification to the left to reveal the Open action, which invokes the intent on the handheld device.

Add Action Buttons

// Build an intent for an action to view a map
Intent mapIntent = new Intent(Intent.ACTION_VIEW);
Uri geoUri = Uri.parse("geo:0,0?q=" + Uri.encode(location));
mapIntent.setData(geoUri);
PendingIntent mapPendingIntent =
       PendingIntent.getActivity(this, 0, mapIntent, 0);

NotificationCompat.Builder notificationBuilder =
       new NotificationCompat.Builder(this)
       .setSmallIcon(R.drawable.ic_event)
       .setContentTitle(eventTitle)
       .setContentText(eventLocation)
       .setContentIntent(viewPendingIntent)
       .addAction(R.drawable.ic_map,
               getString(R.string.map), mapPendingIntent);

On a handheld, the action appears as an additional button attached to the notification. On a wearable, the action appears as a large button when the user swipes the notification to the left. When the user taps the action, the associated intent is invoked on the handheld.

Specify Wearable-only Actions

If you want the actions available on the wearable to be different from those on the handheld, then use WearableExtender.addAction(). Once you add an action with this method, the wearable does not display any other actions added with NotificationCompat.Builder.addAction(). That is, only the actions added with WearableExtender.addAction() appear on the wearable and they do not appear on the handheld.

// Create an intent for the reply action
Intent actionIntent = new Intent(this, ActionActivity.class);
PendingIntent actionPendingIntent =
       PendingIntent.getActivity(this, 0, actionIntent,
               PendingIntent.FLAG_UPDATE_CURRENT);

// Create the action
NotificationCompat.Action action =
       new NotificationCompat.Action.Builder(R.drawable.ic_action,
               getString(R.string.label), actionPendingIntent)
               .build();

// Build the notification and add the action via WearableExtender
Notification notification =
       new NotificationCompat.Builder(mContext)
               .setSmallIcon(R.drawable.ic_message)
               .setContentTitle(getString(R.string.title))
               .setContentText(getString(R.string.content))
               .extend(new WearableExtender().addAction(action))
               .build();



Add a Big View

To add the extended content to your notification, call setStyle() on the NotificationCompat.Builder object, passing it an instance of eitherBigTextStyle or InboxStyle.

// Specify the 'big view' content to display the long
// event description that may not fit the normal content text.
BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();
bigStyle.bigText(eventDescription);

NotificationCompat.Builder notificationBuilder =
       new NotificationCompat.Builder(this)
       .setSmallIcon(R.drawable.ic_event)
       .setLargeIcon(BitmapFactory.decodeResource(
               getResources(), R.drawable.notif_background))
       .setContentTitle(eventTitle)
       .setContentText(eventLocation)
       .setContentIntent(viewPendingIntent)
       .addAction(R.drawable.ic_map,
               getString(R.string.map), mapPendingIntent)
       .setStyle(bigStyle);



Add Wearable Features For a Notification

예시) 

setHintHideIcon(), setBackground()

  1. Create an instance of a WearableExtender, setting the wearable-specific options for the notication.
  2. Create an instance of NotificationCompat.Builder, setting the desired properties for your notification as described earlier in this lesson.
  3. Call extend() on the notification and pass in the WearableExtender. This applies the wearable options to the notification.
  4. Call build() to build the notification.
// Create a WearableExtender to add functionality for wearables
NotificationCompat.WearableExtender wearableExtender =
       new NotificationCompat.WearableExtender()
       .setHintHideIcon(true)
       .setBackground(mBitmap);

// Create a NotificationCompat.Builder to build a standard notification
// then extend it with the WearableExtender
Notification notif = new NotificationCompat.Builder(mContext)
       .setContentTitle("New mail from " + sender)
       .setContentText(subject)
       .setSmallIcon(R.drawable.new_mail)
       .extend(wearableExtender)
       .build();

Note: The bitmap that you use with setBackground() should have a resolution of 400×400 for non-scrolling backgrounds and 640×400 for backgrounds that support parallax scrolling. Place these bitmap images in the res/drawable-nodpi directory. Place other non-bitmap resources for wearable notifications, such as those used with the setContentIcon() method, in the res/drawable-hdpi directory.

If you ever need to read wearable-specific options at a later time, use the corresponding get method for the option. This example calls the getHintHideIcon()

NotificationCompat.WearableExtender wearableExtender =
       new NotificationCompat.WearableExtender(notif);
boolean hintHideIcon = wearableExtender.getHintHideIcon();



Deliver the Notification

When you want to deliver your notifications, always use the NotificationManagerCompat API instead ofNotificationManager:

// Get an instance of the NotificationManager service
NotificationManagerCompat notificationManager =
       NotificationManagerCompat.from(mContext);

// Issue the notification with notification manager.
notificationManager.notify(notificationId, notif);

original source : http://www.androiddocs.com/training/wearables/ui/cards.html

Creating Cards

The Wearable UI Library provides implementations of cards specifically designed for wearable devices. This library contains the CardFrame class, which wraps views inside a card-styled frame. CardFrame can only contain one direct child, 어떤 fragment가 cardFrame안에 들어갈지는 layout manager를 통해 결정한다.  

You can add cards to your app in two ways:

  • Use or extend the CardFragment class.
  • Add a card inside a CardScrollView in your layout.

Note: This lesson shows you how to add cards to Android Wear activities. Android notifications on wearable devices are also displayed as cards. For more information, see Adding Wearable Features to Notifications



Create a Card Fragment

To add a CardFragment to your app:

  1. In your layout, assign an ID to the element that contains the card
  2. Create a CardFragment instance in your activity
  3. Use the fragment manager to add the CardFragment instance to its container
<android.support.wearable.view.BoxInsetLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/robot_background"
android:layout_height="match_parent"
android:layout_width="match_parent">

   <FrameLayout
       android:id="@+id/frame_layout"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       app:layout_box="bottom">

   </FrameLayout>
</android.support.wearable.view.BoxInsetLayout>

The following code adds the CardFragment instance to the activity in Figure 1:

protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_wear_activity2);

   FragmentManager fragmentManager = getFragmentManager();
   FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
   CardFragment cardFragment = CardFragment.create(getString(R.string.cftitle),
                                                   getString(R.string.cfdesc),
                                                   R.drawable.p);
   fragmentTransaction.add(R.id.frame_layout, cardFragment);
   fragmentTransaction.commit();
}

To create a card with a custom layout using CardFragment, extend this class and override its onCreateContentView method.

Add a CardFrame to Your Layout

You can also add a card directly to your layout definition,

<android.support.wearable.view.BoxInsetLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/robot_background"
android:layout_height="match_parent"
android:layout_width="match_parent">

   <android.support.wearable.view.CardScrollView
       android:id="@+id/card_scroll_view"
       android:layout_height="match_parent"
       android:layout_width="match_parent"
       app:layout_box="bottom">

       <android.support.wearable.view.CardFrame
           android:layout_height="wrap_content"
           android:layout_width="fill_parent">

           <LinearLayout
               android:layout_height="wrap_content"
               android:layout_width="match_parent"
               android:orientation="vertical"
               android:paddingLeft="5dp">
               <TextView
                   android:fontFamily="sans-serif-light"
                   android:layout_height="wrap_content"
                   android:layout_width="match_parent"
                   android:text="@string/custom_card"
                   android:textColor="@color/black"
                   android:textSize="20sp"/>
               <TextView
                   android:fontFamily="sans-serif-light"
                   android:layout_height="wrap_content"
                   android:layout_width="match_parent"
                   android:text="@string/description"
                   android:textColor="@color/black"
                   android:textSize="14sp"/>
           </LinearLayout>
       </android.support.wearable.view.CardFrame>
   </android.support.wearable.view.CardScrollView>
</android.support.wearable.view.BoxInsetLayout>
@Override
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_wear_activity2);

   CardScrollView cardScrollView =
       (CardScrollView) findViewById(R.id.card_scroll_view);
   cardScrollView.setCardGravity(Gravity.BOTTOM);
}

original source : http://www.androiddocs.com/training/wearables/ui/confirm.html

Showing Confirmations

The Wearable UI Library helps you show confirmation animations and timers in your Android Wear apps:

  • Confirmation timers          Automatic confirmation timers show users an animated timer that lets them cancel an action they just performed.
  • Confirmation           animationsConfirmation animations give users visual feedback when they complete an action. 

아래 confirmation timer는 deprecated 되었다.
https://developer.android.com/training/wearables/ui/confirm.html
를 대신 이용할것

Use Automatic Confirmation Timers

image

Automatic confirmation timers let users cancel an action they just performed. When the user performs the action, your app shows a button to cancel the action with a timer animation and starts the timer. The user has the option to cancel the action until the timer finishes. Your app gets notified if the user cancels the action and when the timer expires.

To show a confirmation timer when users complete an action in your app:

  1. Add a DelayedConfirmationView element to your layout.
  2. Implement the DelayedConfirmationListener interface in your activity.
  3. Set the duration of the timer and start it when the user completes an action.
<android.support.wearable.view.DelayedConfirmationView
   android:id="@+id/delayed_confirm"
   android:layout_width="40dp"
   android:layout_height="40dp"
   android:src="@drawable/cancel_circle"
   app:circle_border_color="@color/lightblue"
   app:circle_border_width="4dp"
   app:circle_radius="16dp">
</android.support.wearable.view.DelayedConfirmationView>

You can assign a drawable resource to display inside the circle with the android:src attribute and configure the parameters of the circle directly on the layout definition.

To be notified when the timer finishes or when users tap on it, implement the corresponding listener methods in your activity:

public class WearActivity extends Activity implements
                          DelayedConfirmationView.DelayedConfirmationListener {

   private DelayedConfirmationView mDelayedView;

   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_wear_activity);

       mDelayedView =
               (DelayedConfirmationView) findViewById(R.id.delayed_confirm);
       mDelayedView.setListener(this);
   }

   @Override
   public void onTimerFinished(View view) {
       // User didn't cancel, perform the action
   }

   @Override
   public void onTimerSelected(View view) {
       // User canceled, abort the action
   }
}

To start the timer

// Two seconds to cancel the action
mDelayedView.setTotalTimeMs(2000);
// Start the timer
mDelayedView.start();



Show Confirmation Animations

image

To show a confirmation animation when users complete an action in your app, create an intent that starts ConfirmationActivity from one of your activities. You can specify one of the these animations with the EXTRA_ANIMATION_TYPE intent extra:

  • SUCCESS_ANIMATION
  • FAILURE_ANIMATION
  • OPEN_ON_PHONE_ANIMATION

You can also add a message that appears under the confirmation icon.

<manifest>
 <application>
   ...
   <activity
       android:name="android.support.wearable.activity.ConfirmationActivity">
   </activity>
 </application>
</manifest>
Intent intent = new Intent(this, ConfirmationActivity.class);
intent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE,
               ConfirmationActivity.SUCCESS_ANIMATION);
intent.putExtra(ConfirmationActivity.EXTRA_MESSAGE,
               getString(R.string.msg_sent));
startActivity(intent);

After showing the confirmation animation, ConfirmationActivity finishes and your activity resumes.