• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.plugins.activity;
6 
7 import android.app.Activity;
8 import android.support.annotation.NonNull;
9 
10 import io.flutter.plugin.common.PluginRegistry;
11 import io.flutter.plugin.platform.PlatformViewsController;
12 
13 /**
14  * Binding that gives {@link ActivityAware} plugins access to an associated {@link Activity} and
15  * the {@link Activity}'s lifecycle methods.
16  */
17 public interface ActivityPluginBinding {
18 
19   /**
20    * Returns the {@link Activity} that is currently attached to the {@link FlutterEngine} that
21    * owns this {@code ActivityPluginBinding}.
22    */
23   @NonNull
getActivity()24   Activity getActivity();
25 
26   /**
27    * Adds a listener that is invoked whenever the associated {@link Activity}'s
28    * {@code onRequestPermissionsResult(...)} method is invoked.
29    */
addRequestPermissionsResultListener(@onNull PluginRegistry.RequestPermissionsResultListener listener)30   void addRequestPermissionsResultListener(@NonNull PluginRegistry.RequestPermissionsResultListener listener);
31 
32   /**
33    * Removes a listener that was added in {@link #addRequestPermissionsResultListener(PluginRegistry.RequestPermissionsResultListener)}.
34    */
removeRequestPermissionsResultListener(@onNull PluginRegistry.RequestPermissionsResultListener listener)35   void removeRequestPermissionsResultListener(@NonNull PluginRegistry.RequestPermissionsResultListener listener);
36 
37   /**
38    * Adds a listener that is invoked whenever the associated {@link Activity}'s
39    * {@code onActivityResult(...)} method is invoked.
40    */
addActivityResultListener(@onNull PluginRegistry.ActivityResultListener listener)41   void addActivityResultListener(@NonNull PluginRegistry.ActivityResultListener listener);
42 
43   /**
44    * Removes a listener that was added in {@link #addActivityResultListener(PluginRegistry.ActivityResultListener)}.
45    */
removeActivityResultListener(@onNull PluginRegistry.ActivityResultListener listener)46   void removeActivityResultListener(@NonNull PluginRegistry.ActivityResultListener listener);
47 
48   /**
49    * Adds a listener that is invoked whenever the associated {@link Activity}'s
50    * {@code onNewIntent(...)} method is invoked.
51    */
addOnNewIntentListener(@onNull PluginRegistry.NewIntentListener listener)52   void addOnNewIntentListener(@NonNull PluginRegistry.NewIntentListener listener);
53 
54   /**
55    * Removes a listener that was added in {@link #addOnNewIntentListener(PluginRegistry.NewIntentListener)}.
56    */
removeOnNewIntentListener(@onNull PluginRegistry.NewIntentListener listener)57   void removeOnNewIntentListener(@NonNull PluginRegistry.NewIntentListener listener);
58 
59   /**
60    * Adds a listener that is invoked whenever the associated {@link Activity}'s
61    * {@code onUserLeaveHint()} method is invoked.
62    */
addOnUserLeaveHintListener(@onNull PluginRegistry.UserLeaveHintListener listener)63   void addOnUserLeaveHintListener(@NonNull PluginRegistry.UserLeaveHintListener listener);
64 
65   /**
66    * Removes a listener that was added in {@link #addOnUserLeaveHintListener(PluginRegistry.UserLeaveHintListener)}.
67    */
removeOnUserLeaveHintListener(@onNull PluginRegistry.UserLeaveHintListener listener)68   void removeOnUserLeaveHintListener(@NonNull PluginRegistry.UserLeaveHintListener listener);
69 }
70