1 /* This file is part of NIT ( http://www.nitlanguage.org ).
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
18 import android
.app
.Activity
;
19 import android
.os
.Bundle
;
22 * Entry point to Nit applications on Android, redirect most calls to Nit
24 public class NitActivity
extends Activity
{
26 // Nit activity associated to `this`
27 protected int nitActivity
= 0;
30 * Calls to Nit or to the C framework
34 System
.loadLibrary("main");
38 * Callbacks to Nit through C
40 protected native int nitRegisterActivity();
41 protected native void nitOnCreate(int activity
, Bundle savedInstanceState
);
42 protected native void nitOnStart(int activity
);
43 protected native void nitOnRestart(int activity
);
44 protected native void nitOnResume(int activity
);
45 protected native void nitOnPause(int activity
);
46 protected native void nitOnStop(int activity
);
47 protected native void nitOnDestroy(int activity
);
48 protected native void nitOnSaveInstanceState(int activity
, Bundle savedInstanceState
);
49 protected native void nitOnRestoreInstanceState(int activity
, Bundle savedInstanceState
);
52 * Implementation of OS callbacks
56 public void onCreate(Bundle savedInstanceState
) {
57 super.onCreate(savedInstanceState
);
59 nitActivity
= nitRegisterActivity();
61 nitOnCreate(nitActivity
, savedInstanceState
);
65 protected void onStart() {
67 nitOnStart(nitActivity
);
71 protected void onRestart() {
73 nitOnRestart(nitActivity
);
77 protected void onResume() {
79 nitOnResume(nitActivity
);
83 protected void onPause() {
85 nitOnPause(nitActivity
);
89 protected void onStop() {
91 nitOnStop(nitActivity
);
95 protected void onDestroy() {
97 nitOnDestroy(nitActivity
);
101 public void onSaveInstanceState(Bundle savedInstanceState
) {
102 super.onSaveInstanceState(savedInstanceState
);
103 nitOnSaveInstanceState(nitActivity
, savedInstanceState
);
107 public void onRestoreInstanceState(Bundle savedInstanceState
) {
108 super.onRestoreInstanceState(savedInstanceState
);
109 nitOnRestoreInstanceState(nitActivity
, savedInstanceState
);