b0767d6987b2773786a66e42728801a3bc73bd04
[nit.git] / lib / android / service / NitService.java
1 /* This file is part of NIT ( http://www.nitlanguage.org ).
2 *
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
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
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.
14 */
15
16 package nit.app;
17
18 import android.app.Service;
19 import android.content.Intent;
20 import android.os.IBinder;
21
22 // Service implemented in Nit
23 public class NitService extends Service {
24
25 protected int nitService = 0;
26
27 static {
28 System.loadLibrary("nit_app");
29 }
30
31 @Override
32 public int onStartCommand(Intent intent, int flags, int id) {
33 return nitOnStartCommand(nitService, intent, flags, id);
34 }
35
36 @Override
37 public void onCreate() {
38 nitService = nitNewService();
39 nitOnCreate(nitService);
40 super.onCreate();
41 }
42
43 @Override
44 public void onDestroy() {
45 nitOnDestroy(nitService);
46 super.onDestroy();
47 }
48
49 @Override
50 public IBinder onBind(Intent arg) {
51 return null;
52 }
53
54 protected native int nitNewService();
55 protected native int nitOnStartCommand(int nitService, Intent intent, int flags, int id);
56 protected native void nitOnCreate(int nitService);
57 protected native void nitOnDestroy(int nitService);
58 }