How to develop and package Android Wear App using Eclips

Google rolled out Google Play services 5.0 to all supported devices worldwide, which including Android wearable services APIs on 2nd July 2014. Since then, we start to work on an Android Wear companion app for InstaB (Social Network for new Parents)https://play.google.com/store/apps/details?id=com.iconmobi.instab

However, it took us a while to figure out how to do it using Eclipse as most of the guide provided are for Android Studio. Thanks to the helpful Android Wear Developer Communities on Google+, we finally manage to complete and launch the first simple version of InstaB companion app for Android Wear.

We decided to put the step by step on how to setup and package an Android Wear app using Eclipse.

First of all, we assumed that you already have Eclipse setup with the latest ADT (Android Development Tools). If not, please do so, you can find the steps here. http://developer.android.com/tools/sdk/eclipse-adt.html

Once you have the latest ADT installed, you need to download the latest Android 4.4W SDK. Start Android SDK Manager and find for Android 4.4W (API 20) and check it all and proceed to install it.


Now, before you start to create an Android Wear project, you’ll need the Android Wear Support library (android.support.wearable). To use this, you need to manually extract it out from Google Support Repository and add it to your workspace.

In order to add this to your workspace, please follow the steps below:

Go to your Android SDK folder, and find this file, ./extras/google/m2repository/com/google/android/support/wearable/1.0.0/wearable-1.0.0.aar

Copy the wearable-1.0.0.aar to a new location that you preferred. Then rename it to zip file before extracting it. After you extract it, create alibs folder and copy classes.jar into the libs folder.

Next step is to add this Android Wear Support library to your Eclipse workspace.

Create a new Android project and choose import from existing code and pick the wearable-1.0.0 folder that you’d just extracted. Remember to go to your project properties and tick the “Is Library” checkbox. And you are ready to go.




Now it’s time to create your first Android Wear project.

Create a new Android Project and follow the settings as below:

And in the Create Activity screen, choose Blank Wear Activity as below:

Important Note: If you are running on latest ADT , you might not have the wizard to create Blank Wear Activity. In this case, you need to manually import the blank wear project template to your project. This template can be downloaded athttps://github.com/tangtungai/Android-Wear-Black-Activity-Template


Ok, now you had created your Android Wear project on Eclipse. But when you open your MainActivity.java, you’ll see error as below whereandroid.support.wearable.view.WatchViewStub is not found.

Still remember the wearable-1.0.0 library that we added to workspace earlier? Now, in your Android Wear project, go to your Project properties and add this wearable-1.0.0 in as library.

This will resolved the issue earlier regarding the missing library.

There is just more one thing. Now, in your project, open yourstyles.xml and change your application theme to default as shown below:

and you are ready to go.


Let’s try to run your project on Android Wear Emulator

To do this, you need to setup your Android Wear Emulator. Open your Android Virtual Device (AVD) Manager and create a new Virtual Device for your Android Wear as below:

This will create a new emulator in your virtual device list. To start, just choose the emulator and click Start.


And your Android Wear emulator will look like this. You’ll notice that there is a cloud icon beside the battery icon. This cloud icon mean that your Android Wear is not paired/connected to any devices.


To connect it to your device, you will need an Android device running on Android OS 4.3+ and above. Install Android Wear app from Google Play Store. (https://play.google.com/store/apps/details?id=com.google.android.wearable.app). After that, plug-in your device using USB to your development machine and run command below:

adb -d forward tcp:5601 tcp:5601

And your Android Wear Emulator will be connected to your Android device.


Android Wear app setting on your Android devices. Notice that it show the Emulator is connected.










Notice that the cloud icon no longer shown as it already connected to your devices.



Now, lets start to run your test Android Project.

Remember to choose the Wear Emulator as target device.

And it will run successfully to show you something as below on your Wear Emulator.

So now you can start to develop your Android Wear app and debug it using emulator if you doesn’t have any wear devices. You can learn more about Android Wear SDK athttp://developer.android.com/training/building-wearables.html


Now, it’s time to package your Android Wear app

After you finish developing your Android Wear app, surely you want to release it to Google Play Store. So you’ll need to package it into a normal Android App APK file because Google doesn’t allow Android Wear standalone app as the Android Wear devices cannot download app directly from Google Play Store.

This part can be a little tricky, so please be careful. ☺

First of all, open your DemoWearApp AndroidManifest.xml file, notice that the sample Android Wear app is using packagecom.example.demowearapp and pay attention to the Version Code and Version Name as we will need that too later.

Ok now you’ll need to create a new Project (DemoWearAppOnPhone) for your Android app that will be install on your phone. Please make sure the package name should be the same as your Android Wear app, in this sample it’scom.example.demowearapp

And choose Black Activity if you doesn’t need any activity on your this app on your phone.

Next step is very important where you’ll add in Google Play Services 5.0 to this project. (Before hand, you will need to import Google Play Services to your workspace, more info can be found here,http://developer.android.com/google/play-services/setup.html#Install)

Ok, now open back your DemoWearApp project and generate the signed APK file and rename it to wearable_app.apk

Copy this file and put it into your DemoWearAppOnPhone project at folder /DemoWearAppOnPhone/res/raw/

Still on DemoWearAppOnPhone project, create a new xml file,wearable_app_desc.xml at res/xml/ folder.

Notice that the package name should be same as your DemoWearApp project as well as the <versionCode> and <versionName>.

The value for <rawPathResId> should be wearable_app (this will point it to the signed wear APK you put in res/raw folder earlier)

Next open the AndroidManifest.xml file forDemoWearAppOnPhone project.

Add in the 2 extra meta-data block above. No changes required.

Finally, double check your DemoWearAppOnPhone project structure and make sure it’s like shown below:

And finally, what you need to do is generate a signed APK forDemoWearAppOnPhone and you are ready to release your first Android Wear app.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
城市应急指挥系统是智慧城市建设的重要组成部分,旨在提高城市对突发事件的预防和处置能力。系统背景源于自然灾害和事故灾难频发,如汶川地震和日本大地震等,这些事件造成了巨大的人员伤亡和财产损失。随着城市化进程的加快,应急信息化建设面临信息资源分散、管理标准不统一等问题,需要通过统筹管理和技术创新来解决。 系统的设计思路是通过先进的技术手段,如物联网、射频识别、卫星定位等,构建一个具有强大信息感知和通信能力的网络和平台。这将促进不同部门和层次之间的信息共享、交流和整合,提高城市资源的利用效率,满足城市对各种信息的获取和使用需求。在“十二五”期间,应急信息化工作将依托这些技术,实现动态监控、风险管理、预警以及统一指挥调度。 应急指挥系统的建设目标是实现快速有效的应对各种突发事件,保障人民生命财产安全,减少社会危害和经济损失。系统将包括预测预警、模拟演练、辅助决策、态势分析等功能,以及应急值守、预案管理、GIS应用等基本应用。此外,还包括支撑平台的建设,如接警中心、视频会议、统一通信等基础设施。 系统的实施将涉及到应急网络建设、应急指挥、视频监控、卫星通信等多个方面。通过高度集成的系统,建立统一的信息接收和处理平台,实现多渠道接入和融合指挥调度。此外,还包括应急指挥中心基础平台建设、固定和移动应急指挥通信系统建设,以及应急队伍建设,确保能够迅速响应并有效处置各类突发事件。 项目的意义在于,它不仅是提升灾害监测预报水平和预警能力的重要科技支撑,也是实现预防和减轻重大灾害和事故损失的关键。通过实施城市应急指挥系统,可以加强社会管理和公共服务,构建和谐社会,为打造平安城市提供坚实的基础。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值