1 #ifndef __blip_NativeActivity_hpp 2 #define __blip_NativeActivity_hpp 6 #include <commonc++/Buffer.h++> 7 #include <commonc++/ConditionVar.h++> 8 #include <commonc++/JavaException.h++> 9 #include <commonc++/Mutex.h++> 10 #include <commonc++/Pipe.h++> 11 #include <commonc++/ScopedPtr.h++> 12 #include <commonc++/String.h++> 13 #include <commonc++/Thread.h++> 17 #include <android/native_activity.h> 20 struct ANativeActivity;
26 class DeviceConfiguration;
28 class InputEventQueue;
35 class RenderingContext;
97 void sleep(timespan_ms_t msec);
106 virtual void onCreate(ccxx::ByteBuffer* buffer);
201 virtual void onIdle() = 0;
269 {
return(_config.get()); }
275 {
return(_jvm.get()); }
281 {
return(_renderingContext.get()); }
305 {
return(_window.get()); }
311 {
return(*(_intent.get())); }
351 void setInputEventQueue(AInputQueue* queue);
352 void deleteInputEventQueue();
353 void updateConfiguration();
354 void setWindow(ANativeWindow* window);
358 bool processRequest();
359 void processTimers();
361 ANativeActivity* _activity;
362 ccxx::ScopedPtr<InputEventQueue> _inputEventQueue;
363 ccxx::ScopedPtr<SensorManager> _sensorManager;
364 ccxx::ScopedPtr<DeviceConfiguration> _config;
365 ccxx::ScopedPtr<AssetManager> _assetManager;
366 ccxx::ScopedPtr<StorageManager> _storageManager;
367 ccxx::ScopedPtr<TimerManager> _timerManager;
368 ccxx::ScopedPtr<Window> _window;
369 ccxx::ScopedPtr<RenderingContext> _renderingContext;
370 ccxx::ScopedPtr<ccxx::JavaVirtualMachine> _jvm;
371 ccxx::ScopedPtr<JavaGlue> _java;
372 ccxx::ScopedPtr<Intent> _intent;
373 ccxx::ScopedPtr<Looper> _looper;
375 ccxx::ConditionVar _cond;
376 ccxx::Pipe _eventPipe;
377 ccxx::Pipe _timerPipe;
380 uint_t _savedStateSize;
387 extern void blip_main(ANativeActivity* activity,
void* savedState,
392 #define EXPORT_NATIVE_ACTIVITY(CLASS, FUNCTION) \ 394 void FUNCTION(ANativeActivity* activity, \ 396 size_t savedStateSize) \ 398 blip::blip_main(activity, savedState, savedStateSize, \ 399 new CLASS((void*)activity)); \ 403 #endif // __blip_NativeActivity_hpp Definition: Intent.hpp:19
An asset manager, which provides access to the application's raw asset files.
Definition: AssetManager.hpp:34
virtual void onIdle()=0
Idle callback.
virtual void onWindowFocusChanged(bool hasFocus)
This method is called when the activity's window gains or loses input focus.
Definition: NativeActivity.cpp:307
A native window.
Definition: Window.hpp:19
virtual bool onKeyEvent(const KeyEvent &event)
This method is called when a KeyEvent is received.
Definition: NativeActivity.cpp:452
virtual void onWindowResized()
This method is called when the activity's window has changed size.
Definition: NativeActivity.cpp:323
A class that manages Timers and schedules TimerEvents for delivery when Timers fire.
Definition: TimerManager.hpp:27
ccxx::String getInternalDataPath() const
Get the filesystem path to application-private data in the device's internal storage (e...
Definition: NativeActivity.cpp:486
Definition: StorageManager.hpp:18
virtual void onContentRectChanged(const Rectangle &rect)
This method is called when the rectangle in the activity's window in which content should be placed h...
Definition: NativeActivity.cpp:347
virtual void onWindowRedrawNeeded()
This method is called when the activity's window needs to be redrawn.
Definition: NativeActivity.cpp:331
ccxx::String getExternalDataPath() const
Get the filesystem path to shared data in the device's external storage (e.g., removable flash media)...
Definition: NativeActivity.cpp:494
virtual void onDestroy()
This method is called when the activity is about to be destroyed.
Definition: NativeActivity.cpp:127
Window * getWindow()
Get the native Window for this activity.
Definition: NativeActivity.hpp:304
const Intent & getIntent()
Get the Intent that this activity was launched with.
Definition: NativeActivity.hpp:310
virtual void onPause()
This method is called when the activity is being paused.
Definition: NativeActivity.cpp:111
virtual void onResume()
This method is called when the activity is being resumed.
Definition: NativeActivity.cpp:103
virtual void onConfigurationChanged()
This method is called when the device configuration has changed.
Definition: NativeActivity.cpp:444
StorageManager * getStorageManager()
Get the StorageManager for this activity.
Definition: NativeActivity.cpp:386
void blip_main(ANativeActivity *activity, void *savedState, size_t savedStateSize, NativeActivity *object)
virtual bool onMotionEvent(const MotionEvent &event)
This method is called when a MotionEvent is received.
Definition: NativeActivity.cpp:461
The native rendering context.
Definition: RenderingContext.hpp:24
void finish()
Finish this activity.
Definition: NativeActivity.cpp:135
virtual void onSaveInstanceState(ccxx::ByteBuffer *buffer)
Called when the activity should save its instance state.
Definition: NativeActivity.cpp:299
An abstract base class for sensor events.
Definition: SensorEvent.hpp:20
virtual void onStart()
This method is called when the activity is being started.
Definition: NativeActivity.cpp:95
A container for device configuration information.
Definition: DeviceConfiguration.hpp:116
Intent * newIntent()
Construct a new Intent object.
Definition: NativeActivity.cpp:424
WAV file format details at: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/.
Definition: AccelerometerSensorEvent.cpp:3
SensorManager * getSensorManager()
Get the SensorManager for this activity.
Definition: NativeActivity.cpp:374
ccxx::JavaVirtualMachine * getJavaVirtualMachine()
Get the Java Virtual Machine for this activity.
Definition: NativeActivity.hpp:274
void startActivity(Intent *intent)
Start a new activity with the given intent.
Definition: NativeActivity.cpp:433
CCXX_FWD_DECL(JavaVirtualMachine)
virtual void onCreate(ccxx::ByteBuffer *buffer)
This method is called when the activity is being created.
Definition: NativeActivity.cpp:87
void * NativeContext
Definition: NativeActivity.hpp:43
An abstract base class for all "native" (C++) Android activities.
Definition: NativeActivity.hpp:71
A rectangle in cartesian space.
Definition: Rectangle.hpp:12
virtual void onWindowCreated()
This method is called when the activity's window has been created.
Definition: NativeActivity.cpp:315
virtual void onSensorEvent(const SensorEvent &event)
This method is called when a SensorEvent is received.
Definition: NativeActivity.cpp:470
RenderingContext * getRenderingContext()
Get the rendering context for this activity.
Definition: NativeActivity.hpp:280
virtual ~NativeActivity()
Destructor.
Definition: NativeActivity.cpp:79
A class that provides access to the hardware sensors.
Definition: SensorManager.hpp:23
void showSoftInput(bool forced=false)
Display the soft input method (e.g., a virtual on-screen keyboard).
Definition: NativeActivity.cpp:502
void hideSoftInput()
Hide the soft input method (e.g., a virtual on-screen keyboard).
Definition: NativeActivity.cpp:514
A keyboard input event.
Definition: KeyEvent.hpp:17
void sleep(timespan_ms_t msec)
Definition: NativeActivity.cpp:144
virtual void onLowMemory()
This method is called when the system is running low on memory.
Definition: NativeActivity.cpp:355
NativeActivity(NativeContext context)
Construct a new NativeActivity.
Definition: NativeActivity.cpp:58
A motion input event.
Definition: MotionEvent.hpp:22
TimerManager * getTimerManager()
Get the timer manager for this activity.
Definition: NativeActivity.cpp:397
AssetManager * getAssetManager()
Get the asset manager for this activity.
Definition: NativeActivity.cpp:363
A timer event.
Definition: TimerEvent.hpp:17
virtual void onWindowDestroyed()
This method is called when the activity's window is about to be destroyed.
Definition: NativeActivity.cpp:339
virtual void onTimerEvent(const TimerEvent &event)
This method is called when a TimerEvent has been received.
Definition: NativeActivity.cpp:478
virtual void onStop()
This method is called when the activity is being stopped.
Definition: NativeActivity.cpp:119
Definition: NativeActivityRequest.hpp:35
const DeviceConfiguration * getDeviceConfiguration()
Get the current device configuration.
Definition: NativeActivity.hpp:268