调用CanvasWatchFaceService

时间:2015-08-28 02:32:54

标签: android android-studio wear-os

当我调用“私有类引擎扩展CanvasWatchFaceService.Engine”时,我收到的错误是“没有封闭的类型实例”android.support.wearable.watchface.CanvasWatchFaceService'在范围内'

我已经调用导入类导入android.support.wearable.watchface.CanvasWatchFaceService;但它说这是一个未使用的导入声明

更新:这是我的整个MyWatchFace.java

package com.projects.kainowitzke.googlewatchface;

import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.wearable.watchface.CanvasWatchFaceService;
import android.support.wearable.watchface.WatchFaceService;
import android.view.SurfaceHolder;
import android.support.wearable.watchface.CanvasWatchFaceService;

public class MyWatchface {
}

public class AnalogWatchFaceService extends MyWatchface {

@Override
public WatchFaceService.Engine onCreateEngine() {
    /* provide your watch face implementation */
    return new CanvasWatchFaceService.Engine();
}

/* implement service callback methods */
    private class MyWatchfac extends CanvasWatchFaceService.Engine {

    @Override
    public void onCreate(SurfaceHolder holder) {
        super.onCreate(holder);
        /* initialize your watch face */
    }

    @Override
    public void onPropertiesChanged(Bundle properties) {
        super.onPropertiesChanged(properties);
        /* get device features (burn-in, low-bit ambient) */
    }

    @Override
    public void onTimeTick() {
        super.onTimeTick();
        /* the time changed */
    }

    @Override
    public void onAmbientModeChanged(boolean inAmbientMode) {
        super.onAmbientModeChanged(inAmbientMode);
        /* the wearable switched between modes */
    }

    @Override
    public void onDraw(Canvas canvas, Rect bounds) {
        /* draw your watch face */
    }

    @Override
    public void onVisibilityChanged(boolean visible) {
        super.onVisibilityChanged(visible);
        /* the watch face became visible or invisible */
    }
}

}

1 个答案:

答案 0 :(得分:0)

MyWatchface必须延长CanvasWatchFaceService