Book Image

Android Wearable Programming

By : Steven F. Daniel
Book Image

Android Wearable Programming

By: Steven F. Daniel

Overview of this book

Table of Contents (14 chapters)
Android Wearable Programming
Credits
About the Authors
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Receiving image data using DataApi


In the previous section, we looked at how we can use the DataApi.putDataItem method to send a binary image data to the Android wearable. In this section, we will be taking a look at how we can retrieve the image and display it within our Android wearable watch area:

  1. From the Project Navigator window, open the WearActivity.java file.

  2. Next, modify the WearActivity class and add the following code snippet:

    public class WearActivity extends Activity {
        private TextView mTextView;
        private ImageView imageView;
        private GoogleApiClient mGoogleApiClient;
        private Bitmap imageBitmap;
        private final Handler imageHandler = new  
        Handler();
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_wear);
            final WatchViewStub stub = (WatchViewStub) 
            findViewById(R.id.watch_view_stub);
            stub.setOnLayoutInflatedListener(new 
          ...