0

问题:我试图在我的表盘上添加一个配套应用程序,我认为这很简单,因为添加 android wear 的配置并不难。但我似乎无法在android wear 应用程序中显示装备,因此我可以打开配套配置应用程序。不管我做什么。

我花了一段时间试图解决这个问题,我真的不知道我做错了什么,我安装了谷歌示例,它们显示了设置。其他人能看到到底做错了什么吗?

配套应用程序的 XML 清单

<?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>

移动应用程序等级

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

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) {
    }

}

我真的看不出我做错了什么?小齿轮不会出现在 android wear 应用程序的图标顶部。但它适用于谷歌示例。我已经复制了清单。其他人可以看到我可能做错了什么吗?

任何帮助,将不胜感激。

4

1 回答 1

0

所以我解决了我的问题,我基本上是一个没有正确阅读文档的白痴。我必须包括

<meta-data
 android:name="com.google.android.wearable.watchface.companionConfigurationAction"
            android:value="com.FOOBAR.android.FOOBAR.watchface.CONFIG_HANDHELD" />

在我的穿着清单上。现在一切都很好。所以如果其他人有这个问题,那就是解决方案。

于 2018-02-03T08:22:22.487 回答