Android 如何知道Google Glass TimelineManager LiveCard是否恢复

Android 如何知道Google Glass TimelineManager LiveCard是否恢复,android,android-service,google-glass,google-gdk,Android,Android Service,Google Glass,Google Gdk,我正在使用Google Glass服务开发一个简单的hello world应用程序。在我的应用程序中,我使用了TimelineManager来显示LiveCard。我想在应用程序对用户可见时调用http调用(我的意思是当用户从其他应用程序滚动到我们的应用程序时) 我知道如果我们使用Activity,onResume()会自动调用,但我是在服务中这样做的 请告诉我当应用程序恢复给用户时将调用哪个方法 public class MyGlassService extends Service {

我正在使用Google Glass服务开发一个简单的hello world应用程序。在我的应用程序中,我使用了TimelineManager来显示LiveCard。我想在应用程序对用户可见时调用http调用(我的意思是当用户从其他应用程序滚动到我们的应用程序时)

我知道如果我们使用Activity,onResume()会自动调用,但我是在服务中这样做的

请告诉我当应用程序恢复给用户时将调用哪个方法

public class MyGlassService extends Service {

    private static final String TAG = "SocketService";
    private static final String LIVE_CARD_ID = "livecard";
    private TimelineManager mTimelineManager;
    private LiveCard mLiveCard;
    private TextToSpeech mSpeech;
    private final IBinder mBinder = new MainBinder();

    private TextView txtName, txtBalance;
    private RemoteViews remoteView;
    private WakeLock screenLock;    


    public class MainBinder extends Binder {
        public void sayMessage() {
            mSpeech.speak(getString(R.string.hello_world),
                    TextToSpeech.QUEUE_FLUSH, null);
        }
    }

    @Override
    public void onCreate() {
        super.onCreate();
        mTimelineManager = TimelineManager.from(this);
        mSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(int status) {
                // do nothing
            }
        });

    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        remoteView = new RemoteViews(this.getPackageName(), R.layout.activity_main);
        if (mLiveCard == null) {
            mLiveCard = mTimelineManager.createLiveCard(LIVE_CARD_ID);
            remoteView.setTextViewText(R.id.name, getString(R.string.pre_screen_msg));
            mLiveCard.setViews(remoteView);

        }
        return START_STICKY;
    }   


    @Override
    public void onDestroy() {
        if (mLiveCard != null && mLiveCard.isPublished()) {
            mLiveCard.unpublish();
            mLiveCard = null;
        }
        mSpeech.shutdown();

        mSpeech = null;
        super.onDestroy();
    }

    @Override
    public IBinder onBind(Intent intent) {
        return mBinder;
    }

    public String toHexString(byte[] data) {
        String s = new String(data);
        return s;
    }
}

Live Card不提供精确的生命周期方法,就像activities那样,让您知道用户何时滚动到或滚动离开某个活动

如果您想查看此功能,请在我们的网站上发布一个功能请求,描述您的用例