Flutter Engine
The Flutter Engine
native_activity.h
Go to the documentation of this file.
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#ifndef FLUTTER_TESTING_ANDROID_NATIVE_ACTIVITY_NATIVE_ACTIVITY_H_
6#define FLUTTER_TESTING_ANDROID_NATIVE_ACTIVITY_NATIVE_ACTIVITY_H_
7
8#include <android/native_activity.h>
9
10#include "flutter/fml/macros.h"
11#include "flutter/fml/mapping.h"
12
13namespace flutter {
14
15//------------------------------------------------------------------------------
16/// @brief An instance of a native activity. Users of the
17/// `native_activity_apk` are meant to subclass this and return an
18/// instance of this subclass from `flutter::NativeActivityMain`.
19///
20/// All methods are called on the Android Platform main-thread.
21/// Subclasses will usually re-thread calls to a background thread
22/// for long running tasks as these will lead to ANRs on when
23/// invoked on the platform thread.
24///
26 public:
27 virtual ~NativeActivity();
28
29 //----------------------------------------------------------------------------
30 /// @brief Perform graceful termination of the activity. Will eventually
31 /// lead to the other activity lifecycle callback on the way to
32 /// termination.
33 ///
34 /// Can be called from any thread.
35 ///
36 void Terminate();
37
38 virtual void OnStart();
39
40 virtual void OnStop();
41
42 virtual void OnPause();
43
44 virtual void OnResume();
45
46 virtual std::shared_ptr<fml::Mapping> OnSaveInstanceState();
47
48 virtual void OnWindowFocusChanged(bool has_focus);
49
51
53
55
57
58 virtual void OnInputQueueCreated(AInputQueue* queue);
59
60 virtual void OnInputQueueDestroyed(AInputQueue* queue);
61
62 virtual void OnConfigurationChanged();
63
64 virtual void OnLowMemory();
65
66 protected:
67 explicit NativeActivity(ANativeActivity* activity);
68
69 private:
70 ANativeActivity* activity_ = nullptr;
71
72 FML_DISALLOW_COPY_AND_ASSIGN(NativeActivity);
73};
74
75std::unique_ptr<NativeActivity> NativeActivityMain(
76 ANativeActivity* activity,
77 std::unique_ptr<fml::Mapping> saved_state);
78
79} // namespace flutter
80
81#endif // FLUTTER_TESTING_ANDROID_NATIVE_ACTIVITY_NATIVE_ACTIVITY_H_
An instance of a native activity. Users of the native_activity_apk are meant to subclass this and ret...
virtual void OnNativeWindowCreated(ANativeWindow *window)
virtual void OnNativeWindowResized(ANativeWindow *window)
void Terminate()
Perform graceful termination of the activity. Will eventually lead to the other activity lifecycle ca...
virtual void OnInputQueueDestroyed(AInputQueue *queue)
virtual void OnNativeWindowRedrawNeeded(ANativeWindow *window)
virtual void OnNativeWindowDestroyed(ANativeWindow *window)
NativeActivity(ANativeActivity *activity)
virtual void OnInputQueueCreated(AInputQueue *queue)
virtual void OnConfigurationChanged()
virtual std::shared_ptr< fml::Mapping > OnSaveInstanceState()
virtual void OnWindowFocusChanged(bool has_focus)
GLFWwindow * window
Definition: main.cc:45
VkQueue queue
Definition: main.cc:55
std::unique_ptr< NativeActivity > NativeActivityMain(ANativeActivity *activity, std::unique_ptr< fml::Mapping > saved_state)
void * saved_state
struct ANativeWindow ANativeWindow