-
Notifications
You must be signed in to change notification settings - Fork 22
/
MyService.java
50 lines (40 loc) · 1.09 KB
/
MyService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.example.ndkbinderservice;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import com.example.Constants;
public class MyService extends Service
{
// Used to load the 'native-lib' library on application startup.
static
{
System.loadLibrary("native-lib");
}
private IBinder mBinder;
@Override
public void onCreate()
{
super.onCreate();
mBinder = createServiceBinder();
if(null == mBinder)
{
Log.w(Constants.LOG_TAG, "[MyService] [java] Binder is null");
}
else
{
Log.d(Constants.LOG_TAG, "[MyService] [java] Binder is ready");
}
}
@Override
public IBinder onBind(Intent intent)
{
Log.d(Constants.LOG_TAG, "[MyService] [java] A client binds the service");
return mBinder;
}
/**
* A native method that is implemented by the 'native-lib' native library,
* which is packaged with this application.
*/
public native IBinder createServiceBinder();
}