1 // Copyright 2013 The Flutter Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package io.flutter.embedding.engine.systemchannels; 6 7 import android.support.annotation.NonNull; 8 9 import io.flutter.Log; 10 import io.flutter.embedding.engine.dart.DartExecutor; 11 import io.flutter.plugin.common.BasicMessageChannel; 12 import io.flutter.plugin.common.StringCodec; 13 14 /** 15 * TODO(mattcarroll): fill in javadoc for LifecycleChannel. 16 */ 17 public class LifecycleChannel { 18 private static final String TAG = "LifecycleChannel"; 19 20 @NonNull 21 public final BasicMessageChannel<String> channel; 22 LifecycleChannel(@onNull DartExecutor dartExecutor)23 public LifecycleChannel(@NonNull DartExecutor dartExecutor) { 24 this.channel = new BasicMessageChannel<>(dartExecutor, "flutter/lifecycle", StringCodec.INSTANCE); 25 } 26 appIsInactive()27 public void appIsInactive() { 28 Log.v(TAG, "Sending AppLifecycleState.inactive message."); 29 channel.send("AppLifecycleState.inactive"); 30 } 31 appIsResumed()32 public void appIsResumed() { 33 Log.v(TAG, "Sending AppLifecycleState.resumed message."); 34 channel.send("AppLifecycleState.resumed"); 35 } 36 appIsPaused()37 public void appIsPaused() { 38 Log.v(TAG, "Sending AppLifecycleState.paused message."); 39 channel.send("AppLifecycleState.paused"); 40 } 41 42 } 43