2014年7月4日金曜日

How to packaging watch face app with auto install.

I released a customizable Watch face app for Android.
Band O'Clock for Wear : Google Play


There are some tricks for enable auto-install from phone.

■ AndroidManifest.xml

This is a AndroidManifest.xml for Wear app.
If you set com.google.android.permission.PROVIDE_BACKGROUND permission, auto-install seems not happen, but you can still select this app for watch face.
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     package="my.package.name">  
  4.   
  5.     <uses-feature android:name="android.hardware.type.watch" />  
  6.   
  7.     <!-- if set this, auto-intall not happen -->  
  8.     <!--<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />-->  
  9.   
  10.     <application  
  11.         android:allowBackup="true"  
  12.         android:icon="@drawable/ic_launcher"  
  13.         android:label="@string/app_name"  
  14.         android:theme="@android:style/Theme.DeviceDefault">  
  15.   
  16.         <meta-data  
  17.             android:name="com.google.android.gms.version"  
  18.             android:value="@integer/google_play_services_version" />  
  19.   
  20.         <activity  
  21.             android:name=".MainActivity"  
  22.             android:allowEmbedded="true"  
  23.             android:exported="true"  
  24.             android:label="@string/app_name"  
  25.             android:screenOrientation="portrait">  
  26.   
  27.             <meta-data  
  28.                 android:name="com.google.android.clockwork.home.preview"  
  29.                 android:resource="@drawable/preview" />  
  30.   
  31.             <intent-filter>  
  32.                 <action android:name="android.intent.action.MAIN" />  
  33.                 <category android:name="com.google.android.clockwork.home.category.HOME_BACKGROUND" />  
  34.             </intent-filter>  
  35.         </activity>  
  36.     </application>  
  37.   
  38. </manifest>  



■ build.gradle

For build.gradle I changed

compile 'com.google.android.gms:play-services-wearable:+'

to

compile 'com.google.android.gms:play-services:5.0.+@aar'

for both mobile and wear project.

I'm not sure it really affect to auto-install, I did not confirm yet.


0 件のコメント:

コメントを投稿