[null, {"document_url": "http://www.androprogrammer.com/2015/05/android-wear-how-to-send-data-from.html", "unformatted_src": "http://3.bp.blogspot.com/-wHr7J9TEdOk/VVGSAOw0OBI/AAAAAAAABAE/Uh0nVSSLK4g/s640/androidweartutorial-1.png", "src": "http://3.bp.blogspot.com/-wHr7J9TEdOk/VVGSAOw0OBI/AAAAAAAABAE/Uh0nVSSLK4g/s640/androidweartutorial-1.png", "formatted_filename": "androidweartutorial", "alt_text": "Android Wear sample", "rendered_width": 640, "rendered_height": 320}, null, null, {"document_url": "http://www.androprogrammer.com/2015/05/android-wear-how-to-send-data-from.html", "unformatted_src": "//lh3.googleusercontent.com/--KW9YvJwJpA/AAAAAAAAAAI/AAAAAAAABUA/BCciDnC-cz4/s80-c/photo.jpg", "src": "http://lh3.googleusercontent.com/--KW9YvJwJpA/AAAAAAAAAAI/AAAAAAAABUA/BCciDnC-cz4/s80-c/photo.jpg", "formatted_filename": "photo", "alt_text": "My photo", "rendered_width": 80, "rendered_height": 80}, null, {"document_url": "http://www.androprogrammer.com/2015/05/android-wear-how-to-send-data-from.html", "unformatted_src": "http://4.bp.blogspot.com/-DD70LqDV73A/VUiNVAzPDfI/AAAAAAAAA-c/-1UNqSTJtbE/s1600/ic_feed.png", "src": "http://4.bp.blogspot.com/-DD70LqDV73A/VUiNVAzPDfI/AAAAAAAAA-c/-1UNqSTJtbE/s1600/ic_feed.png", "formatted_filename": "ic feed", "alt_text": "Subcribe to our RSS feeds"}, {"document_url": "http://www.androprogrammer.com/2015/05/android-wear-how-to-send-data-from.html", "unformatted_src": "http://1.bp.blogspot.com/-OH_WHwYQj2M/VUiNVKLdVhI/AAAAAAAAA-g/cHMOlqZx4Zw/s1600/ic_facebook.png", "src": "http://1.bp.blogspot.com/-OH_WHwYQj2M/VUiNVKLdVhI/AAAAAAAAA-g/cHMOlqZx4Zw/s1600/ic_facebook.png", "formatted_filename": "ic facebook", "alt_text": "Join Us on Facebook"}, {"document_url": "http://www.androprogrammer.com/2015/05/android-wear-how-to-send-data-from.html", "unformatted_src": "http://3.bp.blogspot.com/-ph8qgraLnhU/VUiNWpDtO3I/AAAAAAAAA_E/_WJjLDVNa1c/s1600/ic_twitter.png", "src": "http://3.bp.blogspot.com/-ph8qgraLnhU/VUiNWpDtO3I/AAAAAAAAA_E/_WJjLDVNa1c/s1600/ic_twitter.png", "formatted_filename": "ic twitter", "alt_text": "Follow us on Twitter"}, {"document_url": "http://www.androprogrammer.com/2015/05/android-wear-how-to-send-data-from.html", "unformatted_src": "http://1.bp.blogspot.com/-4uH9UMWocoQ/VUiNVwGV-TI/AAAAAAAAA-w/5vMHS9LJ3Y0/s1600/ic_gplus.png", "src": "http://1.bp.blogspot.com/-4uH9UMWocoQ/VUiNVwGV-TI/AAAAAAAAA-w/5vMHS9LJ3Y0/s1600/ic_gplus.png", "formatted_filename": "ic gplus", "alt_text": "Add to Circles"}, {"document_url": "http://www.androprogrammer.com/2015/05/android-wear-how-to-send-data-from.html", "unformatted_src": "http://2.bp.blogspot.com/-m3SJ41c3c6E/VUiNWMaHICI/AAAAAAAAA-0/5tDQ1CVRdRM/s1600/ic_linkdin.png", "src": "http://2.bp.blogspot.com/-m3SJ41c3c6E/VUiNWMaHICI/AAAAAAAAA-0/5tDQ1CVRdRM/s1600/ic_linkdin.png", "formatted_filename": "ic linkdin", "alt_text": "Connect on Linkdin"}, {"document_url": "http://www.androprogrammer.com/2015/05/android-wear-how-to-send-data-from.html", "unformatted_src": "http://3.bp.blogspot.com/-wB5pZTFc5hs/VUiNVKpks0I/AAAAAAAAA-k/pNDRRdFOS_s/s1600/ic_github.png", "src": "http://3.bp.blogspot.com/-wB5pZTFc5hs/VUiNVKpks0I/AAAAAAAAA-k/pNDRRdFOS_s/s1600/ic_github.png", "formatted_filename": "ic github", "alt_text": "Follow us on Github"}, {"document_url": "http://www.androprogrammer.com/2015/05/android-wear-how-to-send-data-from.html", "unformatted_src": "//bluehost-cdn.com/media/partner/images/wasim808/300x250/bh-300x250-04-dy.png", "src": "http://bluehost-cdn.com/media/partner/images/wasim808/300x250/bh-300x250-04-dy.png", "formatted_filename": "bh dy"}, null, null, null, null, null, {"document_url": "http://www.androprogrammer.com/2015/05/android-wear-how-to-send-data-from.html", "unformatted_src": "http://4.bp.blogspot.com/-piOQqsqrT1Y/VUtfo5EplpI/AAAAAAAAA_s/rMwfuaPQBSk/s1600/ic_googleplay.png", "src": "http://4.bp.blogspot.com/-piOQqsqrT1Y/VUtfo5EplpI/AAAAAAAAA_s/rMwfuaPQBSk/s1600/ic_googleplay.png", "formatted_filename": "ic googleplay"}, null, null]
Android Wear: How to send data from Android Wear to Mobile Device ?

by  Wasim Memon / in Android , Android Wear , Listview / with 3 comments /

Android Wear or Let say Smart Watches are new and trending technology. Android apps are updating and they all comes with Android wear support. if you want it is in your app you can find simple Helloworld wear app tutorials easily on Google. but what if you want to explore it more let say you want to display a List view in android wear or get some kind of input from android wear app. so these tutorial is for you. In this tutorial i have created simple list in android wear app in which user click on list item and an app in mobile device gets open. for example you want to display list of songs in android wear app and on the click of that you want to change song in your device or let say you can display to do list on android wear and on the click of list item you can open to do item details inside your mobile app. this list can be infinite and its totally depends on you and apps in android. Step - 1
First of let i start with adding a android wear module in development. If you have already added android wear module in you app you can skip this step. To add right click on your app root folder (name of your app folder) and go to New > Module. Select Android Wear Module and click on next. Give same name in Application name (Mobile app name) and in Module Name write wear. so you can differentiate them. Make sure you give same package name also. because when you send some data through mobile app or wear app MessageApi will check for the same package and pass that data. so if you give different name you won't be able to send or receive data. On the next screen select Blank Wear Activity and on the next screen give proper name to it.

Note - Above steps are for Android studio wizard. Sorry for eclipse developers (Please migrate to AS)

Step - 2
So our android wear module is added. I hope you have no issue in above steps. in the main activity or launcher activity i have created a List (basically list of my tutorials). For learning purpose you can start with same and after that you can change it is as you want. so put below code in appropriate layout files.


wear/layout/rect_activity_list.xml & wear/layout/round_activity_list.xml

Step - 3
List layout is done in Step -2. now let's jump to coding part where i have initialize WearableListView with Array adapter. Using GoogleApiClient i have checked if there is a connection to a android wear from an app or not. we can get all connected nodes or devices using Wearable.NodeApi.getConnectedNodes method. check below code and make sure you understand or go through it for one time so you know what is actually going on. otherwise you will get confused.




Please add above lines of code in manifest file of wear module. because we are using google play service to communicate. otherwise it will give error.

Step - 4
Now android wear module is ready. you can run it separately on emulator and check it. now we require a bridge which can pass android wear message to android mobile app. so when user click on list item in android wear a service get some sort of message and on the basis of that message we start appropriate activity. Using WearableListenerService we will create service which will do same for our app.


Step - 5
In Mobile app put below code to register your service.


That's it...
Now run wear module in android wear emulator and mobile module in device. make sure you are connected. I hope you understand the full tutorial. you can get full source code from my Github repo. if you find it helpful please share this tutorial.

Keep coding... Wasim Memon
 
Enjoyed This Article? Get Free Updates ;-) My free time work Download & Share