6. Android Wear 設計理念
• Launched automatically (⾃自動啟動)
• Glanceable (可⼀一眼瞥⾒見)
• All about suggest and demand (推薦與需求)
• Zero or low interaction (盡可能減少點擊滑動步驟)
Friday, January 30, 15
10. Debugging over Bluetooth
• ⼿手機設定 Debugging over bluetooth
• ⼿手錶設定 ADB Debug
& Debugging over bluetooth
• 執⾏行 ConnectDebugWear.sh
https://gist.github.com/j796160836/9b135a8de4c44846fd82
Friday, January 30, 15
18. Compile Wear in Eclipse
• Install Google Repository in SDK Manager
• Find wearable-1.1.0.aar in SDK
android-sdks/extras/google/m2repository/com/google/android/support/
wearable/1.0.0/wearable-1.1.0.aar
• Rename aar to zip and unzip it
• Import from existing code
• Check it Is Library
• Import google-play-service-lib
https://medium.com/@tangtungai/ef1b34126a5d
Friday, January 30, 15
19. Compile Wear in Android Studio
• Edit Gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:1.1.0'
compile 'com.google.android.gms:play-services-wearable:6.5.87'
}
[Wearable module]
Friday, January 30, 15
21. Packaging Wearables using Ant
1. Export and Sign Wearable Apps APK
(eg: demowearapp.apk)
2. Add a meta-data tag in AndroidManifest.xml
3. Put your wearable binary in res/raw directory
(eg: res/raw/demowearapp.apk)
4. Write reference descriptions xml
(eg: res/xml/wearable_app_desc.xml)
5. Turn off Asset Compression
https://developer.android.com/training/wearables/apps/packaging.html#PackageManually
https://medium.com/@tangtungai/ef1b34126a5d
Friday, January 30, 15
22. Packaging Wearables in Eclipse
1. Export and Sign Wearable Apps APK
(eg: demowearapp.apk)
#!/bin/bash
cd ../wearable-1.1.0
android update lib-project --path .
ant clean release
cd ../DemoWearApp
android update project --path .
ant clean release
key.store=TEST.keystore
key.store.password=PASSWORD
key.alias=KEYSTORE_ALIAS
key.alias.password=PASSWORD
config.logging=true
ant.properties
Generate build.xml
[Wearable project]
Friday, January 30, 15
23. Packaging Wearables in Eclipse
2. Add a meta-data tag in AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<!-- ... -->
<meta-data
android:name="com.google.android.wearable.beta.app"
android:resource="@xml/wearable_app_desc" />
</application>
[Smartphone project]
Friday, January 30, 15
24. Packaging Wearables in Eclipse
3. Put your wearable binary in res/raw directory
(eg: res/raw/demowearapp.apk)
4. Write reference descriptions xml
(eg: res/xml/wearable_app_desc.xml)
<?xml version="1.0" encoding="utf-8"?>
<wearableApp package="com.example.demowearapp">
<versionCode>1</versionCode>
<versionName>1.0</versionName>
<rawPathResId>demowearapp</rawPathResId>
</wearableApp>
[Smartphone project]
Friday, January 30, 15
25. Packaging Wearables in Eclipse
5. Turn off Asset Compression
<target name="-package-resources" depends="-crunch">
<do-only-if-not-library elseText="Library project: do not package resources..." >
<aapt executable="${aapt}"
command="package"
versioncode="${version.code}"
versionname="${version.name}"
debug="${build.is.packaging.debug}"
manifest="${out.manifest.abs.file}"
assets="${asset.absolute.dir}"
androidjar="${project.target.android.jar}"
apkfolder="${out.absolute.dir}"
nocrunch="${build.packaging.nocrunch}"
resourcefilename="${resource.package.file.name}"
resourcefilter="${aapt.resource.filter}"
libraryResFolderPathRefid="project.library.res.folder.path"
libraryPackagesRefid="project.library.packages"
libraryRFileRefid="project.library.bin.r.file.path"
previousBuildType="${build.last.target}"
buildType="${build.target}"
ignoreAssets="${aapt.ignore.assets}">
<res path="${out.res.absolute.dir}" />
<res path="${resource.absolute.dir}" />
<nocompress extension="apk" />
</aapt>
</do-only-if-not-library>
</target>
http://stackoverflow.com/questions/7937368/how-to-pass-arguments-to-aapt-when-building-android-apk
From <sdks_dir>/tools/ant/build.xml, search -package-resources
Add this
[Smartphone project]
Friday, January 30, 15
26. [Smartphone module]
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
wearApp project(':wear')
}
Packaging Wearables in Android Studio
• Edit Gradle
Friday, January 30, 15
34. Notification notification
= new Notification(R.drawable.ic_launcher,
"New Notification!", System.currentTimeMillis());
notification.setLatestEventInfo(this
, "Awesome app"
, "The description", pending);
基本款 Notification
舊寫法 (deprecated
in
API
level
11)
拜託別再寫了哈~
Friday, January 30, 15
69. Android Wear
Google Play ServicesGoogle Play Services
Android Device
Controller
Model
View
Mini
Controller
View
Model
Controller
View
Model
App structure
Android Wear
WatchKit
iOS App
Friday, January 30, 15