Problem: Im trying to add a companion app to my watchface, I thought it would be simple as it wasn't to difficult to add the configuration for android wear. But i cant seem to get the gear to show in the android wear app so i can open the companion configuration app. No matter what I do.
Ive spent a while trying to solve this and i really don't know what Im doing wrong, Ive installed the google examples and they show the settings. Can anyone else see what on earth in doing wrong?
XML MANIFEST FOR COMPANION APP
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="archtectsproductions.linuxwatchface">
<!-- Required to act as a custom watch face. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- All intent-filters for config actions must include the categories
com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION and
android.intent.category.DEFAULT. -->
<application
android:allowBackup="true"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MobileConfig"
android:label="@string/app_name">
<intent-filter>
<action android:name="archtectsproductions.linuxwatchface.CONFIG_DIGITAL" />
<category android:name="com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
GRADEL FOR MOBILE APP
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "archtectsproductions.watchfacelinuxterminal"
minSdkVersion 19
targetSdkVersion 26
versionCode 23
versionName "7"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
provided 'com.google.android.wearable:wearable:2.1.0'
compile 'com.google.android.support:wearable:2.1.0'
wearApp project(':wear')
implementation 'com.google.android.gms:play-services-wearable:11.8.0'
}
JAVA FOR MOBILE CONFIG
package archtectsproductions.linuxwatchface;
import android.app.Activity;
import android.content.ComponentName;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.support.wearable.companion.WatchFaceCompanion;
import android.widget.TextView;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.wearable.PutDataMapRequest;
import com.google.android.gms.wearable.PutDataRequest;
import com.google.android.gms.wearable.Wearable;
public class MobileConfig extends Activity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
private GoogleApiClient mGoogleApiClient;
private String mPeerId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mobileconfiglayout);
mPeerId = getIntent().getStringExtra(WatchFaceCompanion.EXTRA_PEER_ID);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Wearable.API)
.build();
ComponentName name =
getIntent().getParcelableExtra(WatchFaceCompanion.EXTRA_WATCH_FACE_COMPONENT);
TextView label = (TextView) findViewById(R.id.label);
label.setText(label.getText() + " (" + name.getClassName() + ")");
}
@Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
@Override
protected void onStop() {
if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
}
super.onStop();
}
@Override
public void onConnected(Bundle bundle) {
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
}
}
I really can't see what Im doing wrong? The Little gear doesn't appear over the top of the icon in the android wear app. BUT it works for the google examples. Ive copied manifests over. Can anyone else see what i might be doing wrong?
Any help would be appreciated.
So I Solved my problem, I'm basically an idiot who doesn't read documentation properly. I had to include
<meta-data
android:name="com.google.android.wearable.watchface.companionConfigurationAction"
android:value="com.FOOBAR.android.FOOBAR.watchface.CONFIG_HANDHELD" />
In my wear manifest. Everything is fine now. So if anyone else has this problem that's the solution.